在PostgreSQL中为仅1个表设置只读权限

3

我希望将数据库中的某一张表设置为只读。我尝试了以下命令:

ALTER TABLE table SET READ ONLY;

但它不起作用。

有没有什么办法可以做到这一点?


3
当然它不起作用 - 没有这样的选项。如果您想将其设置为“只读”,则需要撤销该表的权限。 - user330315
@a_horse_with_no_name 如何将单个表设置为只读? - dang
1个回答

阿里云服务器只需要99元/年,新老用户同享,点击查看详情
1

我看到了一个答案,希望它有帮助。

REVOKE INSERT, UPDATE, DELETE, TRUNCATE
ON ALL TABLES IN SCHEMA public
FROM public, <target_role>;

Possibly add more roles to the list, but do not forget the role public. Possibly add more schemas to the list, but do not forget the schema public.


针对所有表格的操作,如何针对单个表格执行? - dang

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,