postgresql 在 Postgres 中显示关系、序列和函数的默认访问权限
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14555062/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Display default access privileges for relations, sequences and functions in Postgres
提问by Clint Pachl
After altering the default privileges on a Postgres database object, how can you view them?
更改 Postgres 数据库对象的默认权限后,如何查看它们?
For instance, if you grant all privileges to role_name
for all tables created in the schema schema_name
:
例如,如果您授予role_name
架构中创建的所有表的所有权限schema_name
:
ALTER DEFAULT PRIVILEGES IN SCHEMA schema_name GRANT ALL ON TABLES TO role_name;
回答by Zyphrax
Using the psql(1) interactive terminal
使用 psql(1) 交互式终端
There is another way, at least in recent Postgres versions.
Use the \ddp
command
还有另一种方法,至少在最近的 Postgres 版本中是这样。
使用\ddp
命令
Default access privileges
Owner | Schema | Type | Access privileges
----------------+--------+----------+-------------------
role_x | | function | =X/role_x
role_x | | sequence |
role_x | | table |
role_x | | type | =U/role_x
Read more about it under the Notes section here:
http://www.postgresql.org/docs/9.0/static/sql-alterdefaultprivileges.html
在此处的注释部分阅读更多相关信息:http:
//www.postgresql.org/docs/9.0/static/sql-alterdefaultprivileges.html
回答by Clint Pachl
Using a SQL query
使用 SQL 查询
SELECT
nspname, -- schema name
defaclobjtype, -- object type
defaclacl -- default access privileges
FROM pg_default_acl a JOIN pg_namespace b ON a.defaclnamespace=b.oid;
Where the value of defaclobjtype
is r = relation (table, view), S = sequence, f = function.
其中的值defaclobjtype
是R =关系(表,视图),S =序列,F =函数。
These access privileges are only for newly created objects within the schema namespace.
这些访问权限仅适用于架构命名空间内新创建的对象。
回答by Cheryl Grant
If you join pg_default_act
to pg_namespace
you will only list default privileges that are granted using in the schema.
如果您加入pg_default_act
,pg_namespace
您将只列出在架构中使用授予的默认权限。