进入数据库:
通过 su - 数据库对应的系统管理员
登录后,再使用 psql 命令即可进入数据库。
创建数据库:
create database 数据库;
展示数据库列表:
切换数据库:
\c 数据库
创建用户:
create user 用户名 with password '密码';
给用户分配权限:
grant all privileges on database 数据库 to 用户;
grant all privileges on all tables in schema public to 用户;
创建 schema 表:
create schema 表名;
在指定路径下创建表空间:
create tablespace 表空间 owner 用户 location '路径';
设置数据库默认表空间:
alter database 数据库 set tablespace 表空间;
给指定用户分配表空间的使用权限:
grant all on tablespace 表空间 to 用户;
更多命令可以通过 help 命令查看。
喜欢的点个赞❤吧!