Bird
0
0

What will be the result of this command sequence?

medium📝 query result Q5 of 15
PostgreSQL - Roles and Security
What will be the result of this command sequence?
CREATE ROLE interns NOLOGIN;
CREATE ROLE emma NOLOGIN;
GRANT interns TO emma;
SELECT rolcanlogin FROM pg_roles WHERE rolname = 'emma';
Atrue
Bfalse
CNULL
DError: role does not exist
Step-by-Step Solution
Solution:
  1. Step 1: Check login attribute of emma

    Emma is created with NOLOGIN, so rolcanlogin is false.
  2. Step 2: Understand role membership effect

    Granting interns to emma does not change emma's login ability.
  3. Final Answer:

    false -> Option B
  4. Quick Check:

    NOLOGIN role returns rolcanlogin = false [OK]
Quick Trick: NOLOGIN roles have rolcanlogin = false in pg_roles [OK]
Common Mistakes:
  • Assuming membership changes login ability
  • Expecting true for NOLOGIN roles
  • Confusing role names in query

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes