Postgresql命令速查

psql命令#

列出全部用户: \du

列出数据库:\l

链接数据库:\c [database_name]

列出Schema:\dn

显示表结构:\d [table_name]

管理命令#

/* 创建schema */
CREATE SCHEMA [schema name];

/* 给用户操作schema下全部表的所有权限 */
GRANT USAGE ON SCHEMA [schema_name] TO [user_name];
GRANT ALL ON ALL TABLES IN SCHEMA [schema_name] TO [user_name];

/* 给用户schema下全部表格的只读权限 */
GRANT USAGE ON SCHEMA [schema_name] TO [user_name];
GRANT SELECT ON ALL TABLES IN SCHEMA [schema_name] TO [user_name];

给用户Schema下表格的权限时,需要赋予Schema的USAGE权限,否则访问时会报错:permission denied for schema

comments powered by Disqus