DROPDB(1)
π DROPDB(1) β dropdb, bestie, from the PostgreSQL 13.23 docs π
okay so this is the dropdb page from the PostgreSQL 13.23 documentation, and itβs lowkey iconic because itβs the little utility that deletes a whole PostgreSQL database. The manual title is literally DROPDB(1), and weβre about to break it down so it makes sense. π«Ά
πΈ NAME πΈ
dropdb β remove a PostgreSQL database.
β¨ SYNOPSIS β¨
dropdb [connection-option...] [option...] dbname
π DESCRIPTION π
dropdb destroys an existing PostgreSQL database. not a drill, bestie β the user who executes this command must be a database superuser or the owner of the database. π
Itβs a wrapper around the SQL command DROP DATABASE (DROP_DATABASE(7)). There is no effective difference between dropping databases via this utility and via other methods for accessing the server. Same energy, same result. β¨
π OPTIONS π
dropdb accepts the following command-line arguments:
dbnameβ specifies the name of the database to be removed. Like, the actual database youβre yeeting. π-e,--echoβ echo the commands thatdropdbgenerates and sends to the server. Itβs giving βshow your work.β π-f,--forceβ attempt to terminate all existing connections to the target database before dropping it. SeeDROP DATABASE(DROP_DATABASE(7)) for more information on this option. Lowkey forceful, but thatβs the point. β‘-i,--interactiveβ issues a verification prompt before doing anything destructive. this is your βare you sure, bestie?β moment π-V,--versionβ print thedropdbversion and exit. Cute little flex. π--if-existsβ do not throw an error if the database does not exist. A notice is issued in this case. No drama, just a lil note. π-?,--helpβ show help aboutdropdbcommand line arguments, and exit. The classic βwait, how do I use this?β save. π
dropdb also accepts the following command-line arguments for connection parameters:
-hhost,--host=host β specifies the host name of the machine on which the server is running. If the value begins with a slash, it is used as the directory for the Unix domain socket. Path-coded, iykyk. π-pport,--port=port β specifies the TCP port or local Unix domain socket file extension on which the server is listening for connections. Port check, slay. π-Uusername,--username=username β user name to connect as. Main character login energy. π-w,--no-passwordβ never issue a password prompt. If the server requires password authentication and a password is not available by other means such as a.pgpassfile, the connection attempt will fail. This option can be useful in batch jobs and scripts where no user is present to enter a password. Very βautomation said no humans today.β π€-W,--passwordβ forcedropdbto prompt for a password before connecting to a database. This option is never essential, sincedropdbwill automatically prompt for a password if the server demands password authentication. However,dropdbwill waste a connection attempt finding out that the server wants a password. In some cases it is worth typing-Wto avoid the extra connection attempt. Efficiency queen behavior. π--maintenance-db=dbname β specifies the name of the database to connect to in order to drop the target database. If not specified, thepostgresdatabase will be used; if that does not exist (or is the database being dropped),template1will be used. This can be a connection string. If so, connection string parameters will override any conflicting command line options. Big βwe need a staging areaβ energy. π οΈ
π ENVIRONMENT π
PGHOST,PGPORT,PGUSERβ default connection parameters. The trio that handles where and who. πPG_COLORβ specifies whether to use color in diagnostic messages. Possible values arealways,auto, andnever. Choose your aesthetic. π¨
This utility, like most other PostgreSQL utilities, also uses the environment variables supported by libpq (see Section 33.14). β¨
π©Ί DIAGNOSTICS π©Ί
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. Basically: check the server, check the defaults, check the vibes. π«Ά
π EXAMPLES π
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;
π SEE ALSO π
createdb(1)DROP DATABASE(DROP_DATABASE(7))
π thatβs the whole page: dropdb, straight from PostgreSQL 13.23 documentation, dated 2025, DROPDB(1) and out. slay responsibly, bestie π
π¦ where this page comes from
- opensuse-leap 16.0: postgresql13 13.23-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql13 13.23-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql13 13.23-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql13 13.23-160000.1.1 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms