↑↓ 选择↵ 打开⌫ 切换范围完整搜索

PG.CENTER 连接 PostgreSQL 文档、百科与生态知识。由 Pigsty 维护。

支持中的版本: 当前版本 (18) / 17 / 16 / 15 / 14
开发中的版本: 19 / 20devel
已结束支持的版本: 13 / 12 / 11 / 10 / 9.6 / 9.5 / 9.4 / 9.3 / 9.2 / 9.1 / 9.0 / 8.4 / 8.3 / 8.2 / 8.1 / 8.0 / 7.4 / 7.3
历史版本。 PostgreSQL 7.3 已结束支持。 请参阅 当前版本手册.

2.7. 权限 #

当你创建一个数据库对象时,你就成为它的所有者。默认情况下,只有对象的所有者才能对对象做任何操作。为了让其他用户能够使用它,必须授予权限。(也有一些用户拥有超级用户权限。这些用户总是可以访问任何对象。)

注意

要更改表、索引、序列或视图的所有者,请使用 ALTER TABLE 命令。

有多种不同的权限:SELECT、INSERT、UPDATE、DELETE、RULE、REFERENCES、TRIGGER、CREATE、TEMPORARY、EXECUTE、USAGE 和 ALL PRIVILEGES。关于 PostgreSQL 支持的各种权限类型的完整信息,请参阅 GRANT 参考页。后面的各节和各章还会向你展示这些权限是如何使用的。

修改或销毁对象的权利始终只属于该对象的拥有者。

要分配权限,使用 GRANT 命令。used. So, if joe is an existing user, and accounts is an existing table, the privilege to update the table can be granted with

GRANT UPDATE ON accounts TO joe;

The user executing this command must be the owner of the table. To grant a privilege to a group, use

GRANT SELECT ON accounts TO GROUP staff;

The special “user” name PUBLIC can be used to grant a privilege to every user on the system. Writing ALL in place of a specific privilege specifies that all privileges will be granted.

要收回权限,使用名字同样贴切的 REVOKE command:

REVOKE ALL ON accounts FROM PUBLIC;

The special privileges of the table owner (i.e., the right to do DROP, GRANT, REVOKE, etc) are always implicit in being the owner, and cannot be granted or revoked. But the table owner can choose to revoke his own ordinary privileges, for example to make a table read-only for himself as well as others.

报告文档问题

阅读 上游文档. 反馈更正前请先核对 当前版本手册.