w3resource

PostgreSQL User and Role Management Queries


This resource offers a total of 50 PostgreSQL Creating and managing roles and users problems for practice. It includes 10 main exercises, each accompanied by solutions, detailed explanations, and four related problems.

Following exercises cover to Creating and managing roles and users PostgreSQL performance.

1. Create a New Role

Write a PostgreSQL query to create a new role named data_analyst with login privileges.

Click me to see the solution

2. Create a User with a Password

Write a PostgreSQL query to create a new user named app_user with a password.

Click me to see the solution

3. Grant SELECT Privileges to a User

Write a PostgreSQL query to grant SELECT privileges on the employees table to the user data_analyst.

Click me to see the solution

4. Revoke a User’s Privileges

Write a PostgreSQL query to revoke INSERT privileges on the orders table from the user sales_rep.

Click me to see the solution

5. Change a User’s Password

Write a PostgreSQL query to update the password for the user app_user to a new value.

Change a User’s Password.

6. Assign a User to a Role

Write a PostgreSQL query to grant the role data_admin to the user alen_king.

Click me to see the solution

7. List All Users and Roles

Write a PostgreSQL query to list all users and roles in the database.

Click me to see the solution

8. Remove a User

Write a PostgreSQL query to delete the user temp_user.

Click me to see the solution

9. Lock a User Account

Write a PostgreSQL query to disable the login capability for inactive_user.

Click me to see the solution

10. Create a Role with Limited Connection Attempts

Write a PostgreSQL query to create a role limited_user with a maximum of 3 connections.

Click me to see the solution

More to Come !

Do not submit any solution of the above exercises at here, if you want to contribute go to the appropriate exercise page.



Follow us on Facebook and Twitter for latest update.