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 that dropdb generates 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. see DROP 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 the dropdb version 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 about dropdb command 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 .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. very "I'm not available to chat rn" ๐Ÿ“ต
  • -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. efficiency queen ๐Ÿ‘‘

  • --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. ๐Ÿงš

๐ŸŒˆ ENVIRONMENT ๐ŸŒˆ

  • PGHOST
  • PGPORT
  • PGUSER

default connection parameters

  • PG_COLOR โ€” specifies whether to use color in diagnostic messages. possible values are always, auto and never. 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 ๐Ÿซถโœจ