Bird
0
0

You have two policies on table projects:

hard📝 Application Q9 of 15
PostgreSQL - Roles and Security
You have two policies on table projects:
CREATE POLICY user_policy ON projects FOR SELECT USING (owner = current_user);
CREATE POLICY admin_policy ON projects FOR SELECT TO admins USING (true);

If user bob is in group admins, what rows will he see?
AOnly rows where owner = 'bob', ignoring admin_policy.
BAll rows, because admin_policy allows all admins to see all rows.
CNo rows, because policies conflict.
DOnly rows where owner = 'bob' and user is admin.
Step-by-Step Solution
Solution:
  1. Step 1: Understand multiple policies

    Multiple policies are combined with OR logic for access.
  2. Step 2: Apply policies for user bob in admins

    admin_policy allows all rows for admins, so bob sees all rows.
  3. Final Answer:

    All rows, because admin_policy allows all admins to see all rows. -> Option B
  4. Quick Check:

    Multiple policies combine with OR = All rows, because admin_policy allows all admins to see all rows. [OK]
Quick Trick: Multiple policies combine with OR, granting access if any match. [OK]
Common Mistakes:
  • Thinking policies combine with AND
  • Ignoring admin_policy for admins
  • Assuming conflict denies access

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes