PostgreSQL · Concept
Row-level security
PostgreSQL row-level security policies control table access one row at a time. After enabled, normal reads and writes must satisfy an applicable policy; otherwise access is denied.
Last updated
Syntax
ALTER TABLE table_name ENABLE ROW LEVEL SECURITY;
CREATE POLICY policy_name ON table_name [ AS { PERMISSIVE | RESTRICTIVE } ] [ FOR { ALL | SELECT | INSERT | UPDATE | DELETE } ] [ TO role_name [, ...] ] [ USING ( using_expression ) ] [ WITH CHECK ( check_expression ) ];In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.
SubscribeRelated
ALTER TABLE ... ENABLE ROW LEVEL SECURITYCREATE POLICYUSINGWITH CHECKBYPASSRLSsecurity-definer functions