Problem Statement
What does Row-Level Security (RLS) enforce?
Explanation
RLS adds a row predicate evaluated per user or role. It enables multi-tenant isolation inside a single table. Keep predicates SARGable and index the filtering columns to avoid slow plans.
Code Solution
SolutionRead Only
ALTER TABLE invoices ENABLE ROW LEVEL SECURITY;
CREATE POLICY p_tenant ON invoices
USING (tenant_id = current_setting('app.tenant')::int);Practice Sets
This question appears in the following practice sets:
