Database Management
PostgreSQL
Subjective
Sep 25, 2025
Explain PostgreSQL row-level security (RLS).
Detailed Explanation
RLS allows tables to have policies that restrict which rows users can see or modify.
Example:
-- Enable RLS on table
ALTER TABLE documents ENABLE ROW LEVEL SECURITY;
-- Create policy
CREATE POLICY user_documents ON documents
FOR ALL TO public
USING (owner_id = current_user_id());
-- Users only see their own documentsBenefits:
• Fine-grained access control
• Transparent to applications
• Multi-tenant applications
• Data privacy compliance
Discussion (0)
No comments yet. Be the first to share your thoughts!
Share Your Thoughts