简体   繁体   English

如何授予特定数据库中架构中所有表的权限?

[英]How do I grant privilges on all tables in a schema in a particular database?

First, here is an overview of how my Postgres is set up首先,这里概述一下我的 Postgres 是如何设置的

I have 3 Databases and within each database there is a schema which shares the same name across all 3 databases.我有 3 个数据库,在每个数据库中都有一个模式,它在所有 3 个数据库中共享相同的名称。

I have written a script to create a role and give it some privileges for the schemas in each database.我编写了一个脚本来创建一个角色并为每个数据库中的模式赋予一些权限。

This is how I grant the privileges to the role:这就是我向角色授予权限的方式:

\c Database1
GRANT SELECT, UPDATE, INSERT ON ALL TABLES IN SCHEMA "schemaName" TO roleName;
\c Database2
GRANT SELECT, UPDATE, INSERT ON ALL TABLES IN SCHEMA "schemaName" TO roleName;
\c Database3
GRANT SELECT, UPDATE, INSERT ON ALL TABLES IN SCHEMA "schemaName" TO roleName;

Is there a way to explicitly state which database I want to affect within the GRANT statement?有没有办法明确 state 我想在 GRANT 语句中影响哪个数据库?

No it is not possible: each database in a instance/cluster is isolated and there is no possibility to reference a database different from the current one (unless you use some extension like dblink or postgres_fdw).不,这是不可能的:实例/集群中的每个数据库都是隔离的,并且不可能引用与当前数据库不同的数据库(除非您使用 dblink 或 postgres_fdw 之类的扩展名)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM