Challenge - 5 Problems
Role Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
What is the output of this role creation query?
Consider the following SQL command executed in PostgreSQL:
What will be the result when you run
CREATE ROLE analyst LOGIN PASSWORD 'secure123' NOSUPERUSER NOCREATEDB NOCREATEROLE NOINHERIT;What will be the result when you run
\du analyst to list this role's attributes?PostgreSQL
CREATE ROLE analyst LOGIN PASSWORD 'secure123' NOSUPERUSER NOCREATEDB NOCREATEROLE NOINHERIT;
Attempts:
2 left
💡 Hint
Look carefully at the keywords NOSUPERUSER, NOCREATEDB, NOCREATEROLE, NOINHERIT and LOGIN.
✗ Incorrect
The command creates a role named 'analyst' that can login but does not have superuser privileges, cannot create databases or roles, and does not inherit privileges from other roles.
📝 Syntax
intermediate1:30remaining
Which option correctly grants a role the ability to create databases?
You want to grant the role 'developer' the permission to create databases. Which of the following SQL commands is syntactically correct and achieves this?
Attempts:
2 left
💡 Hint
Remember the syntax for altering role attributes in PostgreSQL.
✗ Incorrect
The correct syntax to grant the CREATEDB attribute is 'ALTER ROLE role_name CREATEDB;'. The other options are invalid syntax.
🔧 Debug
advanced2:00remaining
Why does this role creation command fail?
You run the following command:
But PostgreSQL returns an error. What is the cause?
CREATE ROLE manager PASSWORD 'pass123' LOGIN;But PostgreSQL returns an error. What is the cause?
PostgreSQL
CREATE ROLE manager PASSWORD 'pass123' LOGIN;
Attempts:
2 left
💡 Hint
Check PostgreSQL documentation for role creation syntax regarding passwords.
✗ Incorrect
In modern PostgreSQL versions, the PASSWORD clause alone is deprecated. You must use ENCRYPTED PASSWORD or specify password encryption explicitly.
🧠 Conceptual
advanced1:30remaining
What is the effect of the NOINHERIT attribute on a role?
In PostgreSQL, what does setting the NOINHERIT attribute on a role do?
Attempts:
2 left
💡 Hint
Think about what inheritance means in role membership.
✗ Incorrect
NOINHERIT means the role does not automatically get privileges from roles it belongs to; it must explicitly SET ROLE to use those privileges.
❓ optimization
expert2:30remaining
Efficiently revoking multiple privileges from a role
You want to revoke the privileges to create databases and create roles from the role 'temp_admin'. Which single SQL command correctly and efficiently revokes both privileges?
Attempts:
2 left
💡 Hint
Remember that CREATEDB and CREATEROLE are role attributes, not privileges on objects.
✗ Incorrect
CREATEDB and CREATEROLE are role attributes set via ALTER ROLE, not privileges revoked with REVOKE. Option A correctly uses ALTER ROLE with NOCREATEDB and NOCREATEROLE.