dropdb  --  Removes a database from the system.


dropdb [ options ] dbname


-h, --host host

This parameter takes the hostname of the machine running postmaster (the backend process). If you are dropping a database on a local backend process and need to specify the directory for the Unix domain socket, prefix host with a slash.

-p, --port port

If connecting to a remote backend process, this parameter needs to provide the TCP/IP port number that the backend is listening on. Otherwise, use it to specify the local socket file extension.

-U, --username username

This parameter takes the username you wish to connect as.

-W, --password

Use this parameter to force a password request.

-e, --echo

Use this parameter to have all queries generated by dropdb echoed to the screen when they are sent to the backend process.

-q, --quiet

Use this parameter to run in quiet mode; this causes the program to exit without displaying any results.

-i, --interactive

Use this parameter to have all actions interactively verified before completing.


This parameter takes the name of the existing database you wish to remove.



This message is displayed if the database is successfully removed.

dropdb: Database removal failed.

This error message is displayed if the program is unable to remove the database. Most of the time this will be due to an issue with the backend process; in this case (if the error is encountered at the backend) the backend error message will be displayed.


The dropdb program performs the same action as SQL's DROP DATABASE command: it removes a database from the system; however, you can call dropdb from the command line, instead of having to open psql. To drop a database with this command (as with DROP DATABASE ), you must be the owner or a database superuser.


The following example demonstrates how to destroy the test database.

$ dropdb test