Bird
0
0

You want to allow user emma to SELECT only the name and email columns from contacts table but deny access to phone. Which sequence of commands achieves this?

hard📝 Application Q8 of 15
PostgreSQL - Roles and Security
You want to allow user emma to SELECT only the name and email columns from contacts table but deny access to phone. Which sequence of commands achieves this?
AGRANT SELECT (name, email) ON contacts TO emma;
BGRANT SELECT (name, email) ON contacts TO emma; REVOKE SELECT (phone) ON contacts FROM emma;
CGRANT SELECT ON contacts TO emma; REVOKE SELECT (phone) ON contacts FROM emma;
DGRANT SELECT ON contacts(name, email) TO emma;
Step-by-Step Solution
Solution:
  1. Step 1: Understand granting partial column permissions

    Granting SELECT on specific columns restricts access to those columns only.
  2. Step 2: Consider REVOKE usage

    Granting SELECT on whole table then revoking phone column denies access to phone.
  3. Step 3: Evaluate options

    GRANT SELECT ON contacts TO emma; REVOKE SELECT (phone) ON contacts FROM emma; grants all columns then revokes phone, achieving the goal.
  4. Final Answer:

    GRANT SELECT ON contacts TO emma; REVOKE SELECT (phone) ON contacts FROM emma; -> Option C
  5. Quick Check:

    Grant all then revoke unwanted columns for selective access [OK]
Quick Trick: Grant all columns then revoke specific columns to deny access [OK]
Common Mistakes:
  • Assuming granting specific columns is enough to deny others
  • Using invalid syntax for column list placement
  • Not revoking unwanted columns explicitly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes