小编kol*_*vra的帖子

禁止在公共模式中创建表

Postgres 版本:9.3.16

假设我们有两个用户,luser并且editor. 我想让它luser(或任何其他非超级用户)不能在公共模式下创建任何表,除了editor. 当我postgres用户身份应用以下内容时,我实现了这一点:

postgres=> select current_user;
 current_user
--------------
 postgres
(1 row)
postgres=# REVOKE ALL ON SCHEMA public FROM PUBLIC;
REVOKE
postgres=# GRANT ALL ON SCHEMA public TO editor WITH GRANT OPTION;
GRANT
postgres=# SET ROLE luser;
SET
postgres=> create table public.test (uid integer);
ERROR:  permission denied for schema public
postgres=> SET ROLE editor;
SET
postgres=> create table public.test (uid integer);
CREATE TABLE
postgres=> \d+
                   List of …
Run Code Online (Sandbox Code Playgroud)

postgresql

6
推荐指数
1
解决办法
2231
查看次数

标签 统计

postgresql ×1