DROPDB(1)
π DROPDB(1) β the dropdb era π
okay bestie, welcome to the dropdb(1) page from the PostgreSQL 15.19 docs. if you're here, you're probably about to delete a database, so hydrate, breathe, and maybe double-check that dbname before you slay too hard. π
β¨ NAME β¨
dropdb β remove a PostgreSQL database ποΈ
π«Ά SYNOPSIS π«Ά
dropdb [connection-option...] [option...] dbname
π DESCRIPTION π
dropdb destroys an existing PostgreSQL database. The user who executes this command must be a database superuser or the owner of the database. no cap, that's the permission vibe check. π
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. so it's giving "same energy, different doorway." πͺβ¨
π OPTIONS π
dropdb accepts the following command-line arguments:
dbnameβ Specifies the name of the database to be removed. this is the main character of the command, so say it with your chest. π-e,--echoβ Echo the commands thatdropdbgenerates and sends to the server. it's giving "show me the receipts." π§Ύ-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. politely but firmly ending the group chat before deleting the chat. π-i,--interactiveβ Issues a verification prompt before doing anything destructive. yes bestie, it asks "are you sure?" before the irreversible part. π-V,--versionβ Print thedropdbversion and exit. tiny info snack. π--if-existsβ Do not throw an error if the database does not exist. A notice is issued in this case. so it won't make a whole scene if the db is already gone. π-?,--helpβ Show help aboutdropdbcommand line arguments, and exit. the "what do these buttons do" button. π
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. π-pport /--port=portβ Specifies the TCP port or local Unix domain socket file extension on which the server is listening for connections. the server's lil door number. πͺπ’-Uusername /--username=usernameβ User name to connect as. hi, it's me, the username. π-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. no awkward password pop-up, but also no magic password rescue. π¬-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. not required, just sometimes a smart lil shortcut. π‘
--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. the backstage database that helps run the drop. π
π ENVIRONMENT π
PGHOST,PGPORT,PGUSERβ Default connection parameters. the usual suspects pulling up with default connection settings. π«ΆPG_COLORβ Specifies whether to use color in diagnostic messages. Possible values arealways,autoandnever. pretty error text? yes pls. πΈ
This utility, like most other PostgreSQL utilities, also uses the environment variables supported by libpq (see Section 34.15). so yeah, libpq's env-var lore applies too. π
π©Ί 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.
π 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))
mwah π this page is from PostgreSQL 15.19, dated 2026, and it's the DROPDB(1) manual page. go forth and drop responsibly, bestie. π«Άβ¨
π¦ where this page comes from
- opensuse-leap 16.0: postgresql15 15.19-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql15 15.19-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql15 15.19-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql15 15.19-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