如何将表标记为只读? [英] How can I mark a table read-only?

查看:80
本文介绍了如何将表标记为只读?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理django网站的迁移,除了django_session表外,我想使所有表均为只读。我该怎么做?

I'm dealing with a migration of a django site, and I'd like make all tables read-only except for the django_session table. How can I do this?

推荐答案

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

可能在列表中添加更多角色,但不要忘记角色 public

可能在列表中添加更多架构,但不要忘记架构 public

手册中的详细信息。

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.
Details in the manual.

超级用户(如 postgres )忽略权限。触发器也可以包括在内。

Superusers (like postgres) ignore permissions. A trigger would be an alternative to include them, too.

这篇关于如何将表标记为只读?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆