在PostgreSQL中将来的表上授予特权? [英] Grant privileges on future tables in PostgreSQL?

查看:178
本文介绍了在PostgreSQL中将来的表上授予特权?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行PostgreSQL 9.3.1。我有 test 数据库和 backup 用户,该用户用于备份数据库。向所有当前表授予特权没有问题,但是每次将新表添加到架构时,我都必须授予特权。

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.

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?

推荐答案

看来解决方案是更改<$的默认特权c $ c> backup 用户:

It looks like the solution is to alter default privileges for backup user:

alter default privileges in schema public grant all on tables to backup;
alter default privileges in schema public grant all on sequences to backup;

这篇关于在PostgreSQL中将来的表上授予特权?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆