Complete the code to create a new login role named 'user1'.
CREATE ROLE [1] LOGIN;The CREATE ROLE command with LOGIN creates a login role. Here, 'user1' is the login role name.
Complete the code to create a group role named 'group1'.
CREATE ROLE [1] NOLOGIN;The NOLOGIN option creates a group role that cannot log in directly.
Fix the error in the code to add the login role 'user1' to the group role 'group1'.
GRANT [1] TO user1;The GRANT command adds a role to another role. Here, 'group1' is granted to 'user1' to make 'user1' a member of 'group1'.
Fill both blanks to check which roles 'user1' is a member of.
SELECT rolname FROM pg_auth_members JOIN pg_roles ON pg_roles.oid = [1] WHERE [2] = (SELECT oid FROM pg_roles WHERE rolname = 'user1');
This query joins pg_auth_members and pg_roles to find roles where 'user1' is a member. roleid is the role granted, and member is the member role.
Fill all three blanks to create a login role 'user2', create a group role 'group2', and add 'user2' to 'group2'.
CREATE ROLE [1] LOGIN; CREATE ROLE [2] NOLOGIN; GRANT [3] TO user2;
First, create the login role 'user2'. Then create the group role 'group2'. Finally, grant 'group2' to 'user2' to add the user to the group.