DROPDB(1)
π DROPDB(1) β the "bye bestie" button for databases π
okay so real talk, this is the dropdb page from the PostgreSQL 14.24 docs, and it's basically the manual for yeeting a whole entire database into the void. yes, the whole thing. no undo. let's get into it π«Ά
β¨ NAME β¨
dropdb β remove a PostgreSQL database. like, gone-gone. π
πΈ SYNOPSIS πΈ
dropdb [connection-option...] [option...] dbname
that's it. that's the whole shape of it. arguments optional, dbname mandatory, vibes immaculate.
π¦ DESCRIPTION π¦
dropdb destroys an existing PostgreSQL database. no cap, destroys. it's the nuclear option and it knows it.
so who's allowed to do this? the user who runs this command has to be either a database superuser or the owner of the database. if that's not youβ¦ it's giving "permission denied" energy, sorry babe π
dropdb is literally just a wrapper around the SQL command DROP DATABASE. and here's the thing β there is no effective difference between dropping databases via this utility and via other methods for accessing the server. same outcome, different outfit. periodt.
π OPTIONS π
dropdb accepts the following command-line arguments:
dbnameβ the name of the database to be removed. this is the main character of the command, the one you're saying goodbye to π-e,--echoβ echo the commands thatdropdbgenerates and sends to the server. so you can literally watch it happen. transparency queen β¨-f,--forceβ attempt to terminate all existing connections to the target database before dropping it. think of it as clearing the room so the demolition can proceed π§ seeDROP DATABASE(DROP_DATABASE(7)) for more info on this option.-i,--interactiveβ issues a verification prompt before doing anything destructive. it's the "are you sure sure" of it all. bestie protection mode π-V,--versionβ print thedropdbversion and exit. quick little flex, then dip.--if-existsβ do not throw an error if the database does not exist. a notice is issued in this case. so polite. so chill. no drama π-?,--helpβ show help aboutdropdbcommand line arguments, and exit. the classic "wait what does this do again" move.
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. sneaky little path trick, iykyk π-pport,--port=port β specifies the TCP port or local Unix domain socket file extension on which the server is listening for connections.-Uusername,--username=username β user name to connect as. pick your fighter π-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. it's for the automation girlies who cannot be interrupted π€-W,--passwordβ forcedropdbto prompt for a password before connecting to a database.
this option is never essential, since dropdb will automatically prompt for a password if the server demands password authentication. however, dropdb will waste a connection attempt finding out that the server wants a password. in some cases it is worth typing -W to avoid the extra connection attempt. lowkey a time-saver, highkey optional π
--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. messy but it works π
π§ ENVIRONMENT π§
PGHOSTPGPORTPGUSER
default connection parameters. the holy trinity of "where am i even connecting" β
PG_COLORβ specifies whether to use color in diagnostic messages. possible values arealways,autoandnever. and yes we love a colorful error message, thank you for asking π
this utility, like most other PostgreSQL utilities, also uses the environment variables supported by libpq (see Section 34.15). so basically the whole libpq env var squad is welcome here too π«Ά
π₯ DIAGNOSTICS π₯
in case of difficulty, see DROP DATABASE (DROP_DATABASE(7)) and psql(1) for discussions of potential problems and error messages. they're the ones who actually explain the β¨whyβ¨.
the database server must be running at the targeted host β no server, no drop, that's just how it is π
also, any default connection settings and environment variables used by the libpq front-end library will apply. so if something's acting weird, check your env, bestie.
π 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 that? it asks. it echoes. it does the thing. chef's kiss, honestly π
π SEE ALSO π
createdb(1)β the opposite energy, for when you're feeling generative πDROP DATABASE(DROP_DATABASE(7)) β the SQL command underneath it all
okay that's the whole page! this absolute icon of a utility shipped with PostgreSQL 14.24, dated 2026, and it's still out here ending databases with grace and zero regrets. go forth, drop responsibly, and please please please double-check your dbname before you hit enter ππ
π¦ where this page comes from
- opensuse-leap 16.0: postgresql14 14.24-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql14 14.24-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql14 14.24-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql14 14.24-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