[英]How to check if row level security is enabled for a table in postgres
Enabling row level security on a table in postgres is pretty straightforward:在 postgres 中的表上启用行级安全性非常简单:
alter table some_table enable row level security;
How would you check to see which tables in a given schema have row level security enabled (for testing)?您将如何检查给定模式中的哪些表启用了行级安全性(用于测试)?
This is stored in pg_class 这存储在pg_class中
relrowsecurity
bool True if table has row level security enabled; relrowsecurity
bool如果表启用了行级安全性, relrowsecurity
true;否则为relrowsecurity
。 see pg_policy catalog relforcerowsecurity
bool True if row level security (when enabled) will also apply to table owner; relforcerowsecurity
bool如果行级安全性(启用时)也适用于表所有者, relforcerowsecurity
true;否则为true。 see pg_policy catalog So you can use: 因此,您可以使用:
select relname, relrowsecurity, relforcerowsecurity
from pg_class
where oid = 'your_table_name'::regclass;
If you want to check if row level security is enabled for lots of tables for a particular schema (in this case public) you can use:如果您想检查是否为特定模式(在本例中为公共)的大量表启用了行级安全性,您可以使用:
select relname, relrowsecurity, relforcerowsecurity
from pg_class
join pg_catalog.pg_namespace n on n.oid = pg_class.relnamespace
where n.nspname = 'public' and relkind = 'r';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.