DROPDB(1)

πŸ“¦ version 14.24, in opensuse-leap 16.0

πŸ‘‘ 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 that dropdb generates 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 🚧 see DROP 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 the dropdb version 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 about dropdb command line arguments, and exit. the classic "wait what does this do again" move.

dropdb also accepts the following command-line arguments for connection parameters:

  • -h host, --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 🐚
  • -p port, --port=port β€” specifies the TCP port or local Unix domain socket file extension on which the server is listening for connections.
  • -U username, --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 .pgpass file, 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 β€” force dropdb to 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, the postgres database will be used; if that does not exist (or is the database being dropped), template1 will 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 🧚

  • PGHOST
  • PGPORT
  • PGUSER

default connection parameters. the holy trinity of "where am i even connecting" ⭐

  • PG_COLOR β€” specifies whether to use color in diagnostic messages. possible values are always, auto and never. 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