0
0
PostgreSQLquery~5 mins

GRANT and REVOKE permissions in PostgreSQL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the GRANT command do in PostgreSQL?
The GRANT command gives specific permissions on database objects to users or roles, allowing them to perform certain actions like SELECT, INSERT, UPDATE, or DELETE.
Click to reveal answer
beginner
What is the purpose of the REVOKE command?
The REVOKE command removes previously granted permissions from users or roles, preventing them from performing certain actions on database objects.
Click to reveal answer
beginner
How do you grant SELECT permission on a table named 'employees' to a user named 'alice'?
Use the command: <br> GRANT SELECT ON employees TO alice;
Click to reveal answer
beginner
How do you revoke INSERT permission on a table named 'sales' from a role named 'sales_team'?
Use the command: <br> REVOKE INSERT ON sales FROM sales_team;
Click to reveal answer
intermediate
Can you grant multiple permissions at once using GRANT? How?
Yes, you can grant multiple permissions by listing them separated by commas. For example: <br> GRANT SELECT, INSERT ON orders TO bob;
Click to reveal answer
Which command gives a user permission to read data from a table?
AGRANT SELECT ON table TO user;
BREVOKE SELECT ON table FROM user;
CGRANT DELETE ON table TO user;
DREVOKE INSERT ON table FROM user;
What does the REVOKE command do?
AGives permissions to users
BCreates a new user
CRemoves permissions from users
DDeletes a table
How would you remove UPDATE permission from user 'john' on table 'products'?
AGRANT UPDATE ON products TO john;
BREVOKE UPDATE ON products FROM john;
CDELETE UPDATE ON products FROM john;
DREMOVE UPDATE ON products FROM john;
Which of the following is a valid way to grant multiple permissions?
AGRANT SELECT, INSERT ON table TO user;
BGRANT SELECT INSERT ON table TO user;
CGRANT (SELECT, INSERT) ON table TO user;
DGRANT SELECT; INSERT ON table TO user;
If you want to allow a user to add new rows to a table, which permission should you grant?
ASELECT
BDELETE
CUPDATE
DINSERT
Explain how to use GRANT and REVOKE commands to control user permissions on a PostgreSQL table.
Think about how you let or stop someone from doing things with your data.
You got /4 concepts.
    Describe a real-life scenario where you would use GRANT and REVOKE in a database.
    Imagine sharing a document with friends and then changing who can edit it.
    You got /3 concepts.