在Postgresql上创建仅用于选择的用户。限制" ALTER TABLE"

时间:2015-09-02 11:56:37

标签: postgresql

我正在使用fallowing脚本来创建用户。

CREATE ROLE readonly LOGIN PASSWORD 'thePwd';

-- Existing objects

GRANT CONNECT ON DATABASE the_db TO readonly;

GRANT USAGE ON SCHEMA public TO readonly;

GRANT SELECT ON ALL TABLES IN SCHEMA public TO readonly;

GRANT SELECT ON ALL SEQUENCES IN SCHEMA public TO readonly;

GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA public TO readonly;

创建用户&角色; " readonly"用户有" SELECT"允许。没有丢弃或截断权限。但是" readonly"用户有权"更改表"命令。

如何限制特定用户"更改表格"权利?

有一个简单的例子吗?

1 个答案:

答案 0 :(得分:0)

解决方案在以下脚本中;

create user dummy_user with nosuperuser encrypted password 'dummy_password';

GRANT CONNECT ON DATABASE the_db TO dummy_user;

GRANT USAGE ON SCHEMA public TO dummy_user;

GRANT SELECT ON ALL TABLES IN SCHEMA public TO dummy_user;

GRANT SELECT ON ALL SEQUENCES IN SCHEMA public TO dummy_user;

GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA public TO dummy_user;