Skip to content
masterclass Buddy

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.

Subscribe
  • ALTER TABLE ... ENABLE ROW LEVEL SECURITY
  • CREATE POLICY
  • USING
  • WITH CHECK
  • BYPASSRLS
  • security-definer functions

Source: PostgreSQL: Documentation: 18: 5.9. Row Security Policies. Checked 2026-11-03.