0
0
PostgreSQLquery~10 mins

Login vs group roles in PostgreSQL - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a new login role named 'user1'.

PostgreSQL
CREATE ROLE [1] LOGIN;
Drag options to blanks, or click blank then click option'
Agroup1
Buser1
Cadmin
Dreadonly
Attempts:
3 left
💡 Hint
Common Mistakes
Using a group role name instead of a login role name.
Forgetting the LOGIN keyword.
2fill in blank
medium

Complete the code to create a group role named 'group1'.

PostgreSQL
CREATE ROLE [1] NOLOGIN;
Drag options to blanks, or click blank then click option'
Agroup1
Breadonly
Cadmin
Duser1
Attempts:
3 left
💡 Hint
Common Mistakes
Using LOGIN keyword for group roles.
Confusing login roles with group roles.
3fill in blank
hard

Fix the error in the code to add the login role 'user1' to the group role 'group1'.

PostgreSQL
GRANT [1] TO user1;
Drag options to blanks, or click blank then click option'
Areadonly
Buser1
Cadmin
Dgroup1
Attempts:
3 left
💡 Hint
Common Mistakes
Granting the login role to the group role instead of the other way.
Using the wrong role names.
4fill in blank
hard

Fill both blanks to check which roles 'user1' is a member of.

PostgreSQL
SELECT rolname FROM pg_auth_members JOIN pg_roles ON pg_roles.oid = [1] WHERE [2] = (SELECT oid FROM pg_roles WHERE rolname = 'user1');
Drag options to blanks, or click blank then click option'
Aroleid
Bmember
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping roleid and member columns.
Using incorrect table aliases.
5fill in blank
hard

Fill all three blanks to create a login role 'user2', create a group role 'group2', and add 'user2' to 'group2'.

PostgreSQL
CREATE ROLE [1] LOGIN;
CREATE ROLE [2] NOLOGIN;
GRANT [3] TO user2;
Drag options to blanks, or click blank then click option'
Auser2
Bgroup2
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up login and group role names.
Granting the login role to the group role.