DROPDB(1)
๐ DROPDB โ the "okay bye bestie" command ๐
ok so like, this is the dropdb page from the PostgreSQL 18.6 docs and honestly? it's giving demolition day. sit down, hydrate, and let's get into it ๐ซถ
โจ NAME โจ
dropdb โ remove a PostgreSQL database. that's it. that's the whole vibe. it deletes a database. permanently. ๐ญ
๐ธ SYNOPSIS ๐ธ
dropdb [connection-option...] [option...] dbname
๐ DESCRIPTION ๐
so dropdb destroys an existing PostgreSQL database. like, gone-gone. no recycle bin, no undo, no "wait bestie I can fix this". ๐ณ๏ธ
and here's the gatekeeping part: the user running this command must be a database superuser or the owner of the database. if you're neither, you're just standing outside the club, respectfully. ๐ซ
also, dropdb is literally just a wrapper around the SQL command DROP DATABASE. no cap โ there is no effective difference between dropping databases via this utility and via any other method of accessing the server. same energy, different outfit. โจ
๐ OPTIONS ๐
dropdb accepts the following command-line arguments:
dbnameโ specifies the name of the database to be removed. the main character, the target, the one getting deleted ๐-e,--echoโ echo the commands thatdropdbgenerates and sends to the server. so you can see exactly what it's saying behind your back ๐-f,--forceโ attempt to terminate all existing connections to the target database before dropping it. seeDROP DATABASE(DROP_DATABASE(7)) for more info on this option. it's giving "everybody out, we're closing" ๐ฅ-i,--interactiveโ issues a verification prompt before doing anything destructive. a lil "u sure bestie?" moment ๐-V,--versionโ print thedropdbversion and exit.--if-existsโ do not throw an error if the database does not exist. a notice is issued in this case. so chill about it fr fr ๐-?,--helpโ show help aboutdropdbcommand line arguments, and exit.
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. ๐-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.-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 "I'm not available to chat rn" ๐ต-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. efficiency queen ๐
--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. ๐ง
๐ ENVIRONMENT ๐
PGHOSTPGPORTPGUSER
default connection parameters
PG_COLORโ specifies whether to use color in diagnostic messages. possible values arealways,autoandnever. bestie we love a colorful error message ๐จ
this utility, like most other PostgreSQL utilities, also uses the environment variables supported by libpq (see Section 32.15).
๐ฉบ 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. so if it's not working, check that the server is even awake first ๐
๐ 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 how it asked first? that's the -i. consent is key ๐โจ
๐ SEE ALSO ๐
createdb(1), DROP DATABASE (DROP_DATABASE(7))
โ ๏ธ ok real talk: dropdb destroys a database. permanently. if you're not a superuser or the database owner, it won't even let you. if you are, please be careful, because there is no undo button and I cannot stress this enough ๐ญ
and that's the whole page, bestie!! this was pulled straight from the PostgreSQL 18.6 docs, dated 2026, and it's DROPDB(1) โ the manual section one, the classic, the icon ๐
now go forth and only drop the databases you actually meant to drop ๐ซถโจ
๐ฆ where this page comes from
- alpine 3.23: postgresql18-doc 18.6-r0 ยท PostgreSQL
- alpine 3.24: postgresql18-doc 18.6-r0 ยท PostgreSQL
- arch rolling: postgresql-libs 18.6-4 ยท PostgreSQL
- fedora 43: postgresql 18.6-1.fc43 ยท PostgreSQL
- fedora 43: postgresql 18.6-1.fc43 ยท PostgreSQL
- fedora 44: postgresql 18.6-1.fc44 ยท PostgreSQL
- fedora 44: postgresql 18.6-1.fc44 ยท PostgreSQL
- nixos 26.05: postgresql 18.6
- ubuntu resolute: postgresql-client-18 18.6-0ubuntu0.26.04.1 ยท PostgreSQL
- ubuntu stonking: postgresql-client-18 18.6-3build2 ยท PostgreSQL
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms