ALTER TABLE orders ENABLE ROW LEVEL SECURITY;
-- Users see only their own orders
CREATE POLICY user_orders ON orders
FOR ALL TO application_role
USING (user_id = current_setting('app.user_id')::INT);
-- Set context in app
SET app.user_id = 42;RLS enforces data isolation at the database layer.