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 ×1