PostgreSQL: Delete database and user

Published at 20 Aug 2025

Using PostgreSQL you might want to delete a database or a user you previously created.

To delete a database, you should run the following query.

DROP DATABASE "project";

To delete a user, you should run the following query.

DROP USER "username";

If the user to be deleted is the owner of a database, you're required to change the owner or delete the database, or you will receive the error role "username" cannot be dropped because some objects depend on it.