授予对 PostgreSQL 中未来表的权限?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22684255/
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
Grant privileges on future tables in PostgreSQL?
提问by Andrey Chernih
I am running PostgreSQL 9.3.1. I have test
database and backup
user which is used to backup the database. I have no problems with granting privileges to all current tables, but I have to grant privileges each time the new table is added to schema.
我正在运行 PostgreSQL 9.3.1。我有用于备份数据库的test
数据库和backup
用户。我对所有当前表授予权限没有问题,但是每次将新表添加到架构时我都必须授予权限。
createdb test
psql test
test=# create table foo();
CREATE TABLE
test=# grant all on all tables in schema public to backup;
GRANT
test=# create table bar();
CREATE TABLE
psql -U backup test
test=> select * from foo;
test=> select * from bar;
ERROR: permission denied for relation bar
Is it possible to grant access to tables which will be created in future without making user owner of the table?
是否可以在不让用户拥有表的情况下授予对将来创建的表的访问权限?
采纳答案by Andrey Chernih
It looks like the solution is to alter default privileges for backup
user:
看起来解决方案是更改backup
用户的默认权限:
alter default privileges in schema public grant all on tables to backup;
alter default privileges in schema public grant all on sequences to backup;