0
0
PostgreSQLquery~20 mins

Table-level permissions in PostgreSQL - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Table Permissions Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2:00remaining
Check SELECT permission effect on query output
Given a table employees with columns id, name, and salary, user alice has only SELECT permission on this table. What will be the result of the query SELECT * FROM employees; when run by alice?
PostgreSQL
SELECT * FROM employees;
AReturns all rows and columns from the employees table.
BReturns no rows but shows the column names.
CRaises a permission denied error.
DReturns only the id and name columns, excluding salary.
Attempts:
2 left
💡 Hint
SELECT permission allows reading all rows and columns unless column-level restrictions exist.
query_result
intermediate
2:00remaining
Effect of missing INSERT permission
User bob tries to insert a new row into the departments table but does not have INSERT permission on it. What happens when bob runs INSERT INTO departments (id, name) VALUES (5, 'Marketing');?
PostgreSQL
INSERT INTO departments (id, name) VALUES (5, 'Marketing');
AThe row is inserted successfully.
BThe query inserts the row but with default values.
CThe query raises a permission denied error.
DThe query runs but does not insert any row.
Attempts:
2 left
💡 Hint
INSERT permission is required to add rows to a table.
📝 Syntax
advanced
2:00remaining
Granting UPDATE permission on a table
Which of the following SQL commands correctly grants UPDATE permission on the projects table to user carol?
AGRANT UPDATE ON projects TO carol;
BGRANT UPDATE projects TO carol;
CGRANT UPDATE ON TABLE projects TO carol;
DGRANT UPDATE ON DATABASE projects TO carol;
Attempts:
2 left
💡 Hint
The correct syntax includes ON TABLE for tables, but ON TABLE is optional in PostgreSQL.
🔧 Debug
advanced
2:00remaining
Diagnose permission error on DELETE
User dave tries to delete rows from the tasks table but gets a permission denied error. The DBA confirms that dave has DELETE permission on the table. What could be the reason for the error?
ADave has DELETE permission but the table is locked by another transaction.
BDave has DELETE permission but lacks TRIGGER permission required by a delete trigger.
CDave has DELETE permission but the table is a view, not a table.
DDave lacks SELECT permission on the table, which is required for DELETE.
Attempts:
2 left
💡 Hint
Some DELETE operations require additional permissions if triggers exist.
🧠 Conceptual
expert
2:00remaining
Understanding role inheritance and table permissions
Role analyst has SELECT permission on the sales table. Role intern is a member of analyst but has no direct permissions on sales. What permissions does intern have on the sales table?
AIntern has no permissions on sales because it has no direct grants.
BIntern has all permissions analyst has plus additional default permissions.
CIntern has only USAGE permission on sales by default.
DIntern inherits SELECT permission on sales through analyst role membership.
Attempts:
2 left
💡 Hint
Role membership allows permission inheritance unless explicitly revoked.