DROPDB(1) PostgreSQL 14.23 Documentation DROPDB(1)
dropdb - remove a PostgreSQL database
| Use Case | Command | Description |
|---|---|---|
| ๐๏ธ Drop a database | dropdb dbname |
Remove a database on the default server |
| ๐ Preview the SQL command | dropdb -e dbname |
Echo the generated DROP DATABASE command |
| ๐ก๏ธ Force disconnect all connections | dropdb -f dbname |
Terminate existing connections before dropping |
| โ Interactive confirmation | dropdb -i dbname |
Prompt for confirmation before deleting |
| ๐ Connect to a remote server | dropdb -h host -p port dbname |
Specify host and port for the database server |
| โญ๏ธ Skip if database does not exist | dropdb --if-exists dbname |
Do not error on missing database |
dropdb [connection-option...] [option...] dbname
dropdb destroys an existing PostgreSQL database. The user who executes this command must be a database superuser or the owner of the database.
dropdb is a wrapper around the SQL command DROP DATABASE. There is no effective difference between dropping databases via this utility and via other methods for accessing the server.
dropdb accepts the following command-line arguments:
dropdb also accepts the following command-line arguments for connection parameters:
This utility, like most other PostgreSQL utilities, also uses the environment variables supported by libpq (see Section 34.15).
In case of difficulty, see DROP DATABASE (DROP_DATABASE(7)) and psql(1) for discussions of potential problems and error messages. The database server must be running at the targeted host. Also, any default connection settings and environment variables used by the libpq front-end library will apply.
To destroy the database demo on the default database server:
$ dropdb demo
To destroy the database demo using the server on host eden, port 5000, with verification and a peek at the underlying command:
$ dropdb -p 5000 -h eden -i -e demo
Database "demo" will be permanently deleted.
Are you sure? (y/n) y
DROP DATABASE demo;
PostgreSQL 14.23 2026 DROPDB(1)
Generated by phpman v4.10.0-7-g98e9fd5 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-09-03 14:48 @216.73.216.75
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)