数据库中创建模式的权限
(1)使用超级用户highgo可以创建schema,但使用普通用户a默认无法创建角色
highgo=#\du
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------+-----------
a | | {}
highgo | Superuser, Create role, Create DB, Replication | {}
highgo=#select current_user;
current_user
--------------
a
(1row)
highgo=#create schema test1;
错误: 对数据库 highgo 权限不够
highgo=#\c highgo highgo
Youare now connected to database "highgo" as user "highgo".
highgo=#select current_user;
current_user
--------------
highgo
(1row)
highgo=#create schema test1;
CREATESCHEMA
(2)在数据库highgo上将create权限赋予a,用户a即可在数据库highgo上创建schema
highgo=#grant create on database highgo to a;
GRANT
highgo=#\c highgo a
Youare now connected to database "highgo" as user "a".
highgo=>create schema test2;
CREATESCHEMA
highgo=>\dn
List of schemas
Name | Owner
----------------+--------
hgdb_catalog | highgo
oracle_catalog | highgo
public | highgo
test2 | a
(4rows)
(3)回收用户a在highgo数据库上的create权限
highgo=#revoke create on database highgo from a;
REVOKE

本文介绍了在Postgres数据库中如何管理创建模式的权限。首先,超级用户可以创建schema,而普通用户默认无此权限。然后,通过将'create'权限授予普通用户,该用户便能在指定数据库上创建schema。最后,演示了如何回收用户的创建权限。
4403

被折叠的 条评论
为什么被折叠?



