0
0
PostgreSQLquery~20 mins

GRANT and REVOKE permissions in PostgreSQL - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Permission Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2:00remaining
What is the effect of this GRANT command?
Consider the following SQL command executed in PostgreSQL:

GRANT SELECT, INSERT ON TABLE employees TO user_jane;

What permissions does user_jane have on the employees table after this command?
Auser_jane can read, add, and delete rows from employees table.
Buser_jane can only read data from employees table.
Cuser_jane can modify table structure of employees.
Duser_jane can read and add new rows to employees table.
Attempts:
2 left
💡 Hint
SELECT allows reading data, INSERT allows adding new rows.
query_result
intermediate
2:00remaining
What happens after this REVOKE command?
Assume user_john has SELECT and UPDATE permissions on the products table.

After running:

REVOKE UPDATE ON products FROM user_john;

Which of the following is true?
Auser_john can still read data but cannot update products.
Buser_john can no longer read data from products.
Cuser_john loses all permissions on products.
Duser_john can update but cannot read products.
Attempts:
2 left
💡 Hint
REVOKE only removes specified permissions.
📝 Syntax
advanced
2:00remaining
Which GRANT command is syntactically correct to give all privileges on a table?
You want to give all possible permissions on the table orders to user_mike.

Which of the following commands is correct in PostgreSQL?
AGRANT ALL ON orders TO user_mike;
BGRANT ALL RIGHTS ON orders TO user_mike;
CGRANT ALL PERMISSIONS ON orders TO user_mike;
DGRANT ALL PRIVILEGES ON orders TO user_mike;
Attempts:
2 left
💡 Hint
PostgreSQL uses 'ALL' without 'PRIVILEGES' keyword.
🧠 Conceptual
advanced
2:00remaining
What is the effect of granting permissions WITH GRANT OPTION?
In PostgreSQL, what does adding WITH GRANT OPTION to a GRANT command do?
ALimits the user to only read data.
BAutomatically revokes permissions after a time.
CAllows the user to grant the same permissions to others.
DPrevents the user from revoking their own permissions.
Attempts:
2 left
💡 Hint
Think about permission delegation.
🔧 Debug
expert
2:00remaining
Why does this REVOKE command fail with an error?
Given the command:

REVOKE SELECT, INSERT FROM user_anna ON TABLE sales;

Why does PostgreSQL raise a syntax error?
AThe order of clauses is incorrect; ON TABLE must come before permissions.
BThe keyword TABLE is not allowed after ON in this context.
CUser names cannot start with 'user_'.
DPermissions must be revoked one at a time.
Attempts:
2 left
💡 Hint
Check the correct syntax order for REVOKE.