Recall & Review
beginner
What is a role in PostgreSQL?
A role in PostgreSQL is an entity that can own database objects and have database privileges. It can represent a user or a group of users.
Click to reveal answer
beginner
How do you create a new role with login capability?
Use the command:
CREATE ROLE role_name LOGIN; This creates a role that can be used to connect to the database.Click to reveal answer
intermediate
What command grants a role the ability to create databases?
Use:
ALTER ROLE role_name CREATEDB; to allow the role to create new databases.Click to reveal answer
intermediate
How can you assign one role to another role (role membership)?
Use:
GRANT role_name TO member_role; to make member_role inherit privileges of role_name.Click to reveal answer
intermediate
How do you remove a role from the database?
Use:
DROP ROLE role_name; to delete the role. Make sure the role owns no database objects or is not connected.Click to reveal answer
Which command creates a role that can log in to the database?
✗ Incorrect
The
CREATE ROLE user1 LOGIN; command creates a role with login permission.How do you allow a role to create new databases?
✗ Incorrect
Use
ALTER ROLE role_name CREATEDB; to grant database creation rights.What does the command
GRANT admin TO user; do?✗ Incorrect
It makes
user a member of admin role, inheriting its privileges.Which command removes a role from PostgreSQL?
✗ Incorrect
The correct command to remove a role is
DROP ROLE role_name;.Can a role in PostgreSQL represent a group of users?
✗ Incorrect
Roles can represent either individual users or groups of users.
Explain how to create a new PostgreSQL role that can log in and create databases.
Think about the commands to create a role and then grant it database creation rights.
You got /3 concepts.
Describe how role membership works in PostgreSQL and how to grant one role to another.
Consider how roles can be grouped by granting one role to another.
You got /3 concepts.