In PostgreSQL, options like PASSWORD must be specified after WITH keyword.
Step 2: Identify the error in the command
The command misses WITH before PASSWORD, causing syntax error.
Final Answer:
PASSWORD must be set using WITH keyword -> Option D
Quick Check:
Use WITH before PASSWORD [OK]
Hint: Use WITH before PASSWORD when creating roles [OK]
Common Mistakes:
Omitting WITH before PASSWORD
Thinking LOGIN disallows PASSWORD
Using ENCRYPTED incorrectly
5. You want to create a role named developer that can log in, create databases, and also inherit permissions from another role team_member. Which command correctly achieves this?
hard
A. CREATE ROLE developer WITH LOGIN CREATEDB INHERIT team_member;
B. CREATE ROLE developer WITH LOGIN CREATEDB INHERIT; GRANT team_member TO developer;
C. CREATE ROLE developer WITH LOGIN CREATEDB INHERIT; ALTER ROLE developer IN ROLE team_member;
D. CREATE ROLE developer WITH LOGIN CREATEDB INHERIT; GRANT developer TO team_member;
Solution
Step 1: Create role with login, createdb, and inherit
The role must be created with WITH LOGIN, CREATEDB, and INHERIT options.
Step 2: Grant membership to inherit permissions
To inherit permissions from team_member, grant team_member role to developer using GRANT.
Step 3: Check each option
CREATE ROLE developer WITH LOGIN CREATEDB INHERIT; GRANT team_member TO developer; correctly creates the role and grants team_member to developer. Others misuse syntax or reverse grant direction.
Final Answer:
CREATE ROLE developer WITH LOGIN CREATEDB INHERIT; GRANT team_member TO developer; -> Option B
Quick Check:
GRANT role TO user for inheritance [OK]
Hint: Use GRANT role TO user to inherit permissions [OK]