← All notes

PostgreSQL row-level security

Answer: Enable it with ALTER TABLE ... ENABLE ROW LEVEL SECURITY, then add policies with CREATE POLICY. With RLS on and no matching policy, the default is deny: no rows are visible or updatable.

ALTER TABLE accounts ENABLE ROW LEVEL SECURITY;

CREATE POLICY account_managers ON accounts TO managers
  USING (manager = current_user);

Policy parts

Admin notes

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted).

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: PostgreSQL Global Development Group, PostgreSQL: Documentation: 18: 5.9. Row Security Policies, PostgreSQL License; PostgreSQL Global Development Group, PostgreSQL: Documentation: 18: CREATE POLICY, PostgreSQL License.

Cite this

Permanent ID: iil:note:absbdq4s

iinventedlight. 2026. "PostgreSQL row-level security." iinventedlight Library, iil:note:absbdq4s, version of 2026-11-04. https://iinventedlight.com/library/notes/postgres-row-level-security/. License: CC-BY-4.0.

@misc{iil_note_absbdq4s,
  author = {{iinventedlight}},
  title = {{PostgreSQL row-level security}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-04},
  url = {https://iinventedlight.com/library/notes/postgres-row-level-security/},
  note = {Permanent ID iil:note:absbdq4s. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com.

For language models and agents: start at /llms.txt. This page in Markdown: /library/notes/postgres-row-level-security.md.