Bird
0
0

Given the table products(id, name, price) and user carol has SELECT permission only on name column, what will be the result of SELECT * FROM products; executed by carol?

medium📝 query result Q4 of 15
PostgreSQL - Roles and Security
Given the table products(id, name, price) and user carol has SELECT permission only on name column, what will be the result of SELECT * FROM products; executed by carol?
AOnly <code>id</code> and <code>name</code> columns will be returned
BAll columns will be returned
COnly the <code>name</code> column values will be returned
DQuery will fail with permission denied error
Step-by-Step Solution
Solution:
  1. Step 1: Understand effect of column-level SELECT permission

    User can only select columns they have permission for.
  2. Step 2: Analyze SELECT * behavior

    SELECT * requests all columns, but user lacks permission on some columns.
  3. Step 3: Determine PostgreSQL behavior

    PostgreSQL will deny the query due to missing permission on some columns.
  4. Final Answer:

    Query will fail with permission denied error -> Option D
  5. Quick Check:

    SELECT * with partial column permission = error [OK]
Quick Trick: SELECT * requires permission on all columns, else error [OK]
Common Mistakes:
  • Assuming partial columns are returned automatically
  • Thinking missing columns are silently omitted
  • Believing query returns only allowed columns without error

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes