PostgreSQL Drop Database

In this article, we will see how to drop PostgreSQL Database. It removes the catalog entries for the database and deletes the directory containing the data. To drop PostgreSQL Database, user must be owner of the database.

PostgreSQL Drop Database Syntax:

DROP DATABASE [ IF EXISTS ] name

PostgreSQL Drop Database Example:

drop database sale;

Lets verify database has been dropped by running either of below queries:

\l
or

select datname from pg_database;

Output:

r2schoolsr2schools=# select datname from pg_database;
datname
-----------
postgres
template1
template0
ecommerce
r2schools

We can also drop database from Linux shell by using dropdb. So we have covered how to drop PostgreSQL database.