DROPDB(1)

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

πŸ’… DROPDB(1) β€” dropdb, bestie, from the PostgreSQL 13.23 docs πŸ’…

okay so this is the dropdb page from the PostgreSQL 13.23 documentation, and it’s lowkey iconic because it’s the little utility that deletes a whole PostgreSQL database. The manual title is literally DROPDB(1), and we’re about to break it down so it makes sense. 🫢

🌸 NAME 🌸

dropdb β€” remove a PostgreSQL database.

✨ SYNOPSIS ✨

dropdb [connection-option...] [option...] dbname

πŸ’– DESCRIPTION πŸ’–

dropdb destroys an existing PostgreSQL database. not a drill, bestie β€” the user who executes this command must be a database superuser or the owner of the database. πŸ‘‘

It’s a wrapper around the SQL command DROP DATABASE (DROP_DATABASE(7)). There is no effective difference between dropping databases via this utility and via other methods for accessing the server. Same energy, same result. ✨

πŸŽ€ OPTIONS πŸŽ€

dropdb accepts the following command-line arguments:

  • dbname β€” specifies the name of the database to be removed. Like, the actual database you’re yeeting. πŸ’…
  • -e, --echo β€” echo the commands that dropdb generates and sends to the server. It’s giving β€œshow your work.” πŸ“
  • -f, --force β€” attempt to terminate all existing connections to the target database before dropping it. See DROP DATABASE (DROP_DATABASE(7)) for more information on this option. Lowkey forceful, but that’s the point. ⚑
  • -i, --interactive β€” issues a verification prompt before doing anything destructive. this is your β€œare you sure, bestie?” moment πŸ›‘
  • -V, --version β€” print the dropdb version and exit. Cute little flex. πŸŽ€
  • --if-exists β€” do not throw an error if the database does not exist. A notice is issued in this case. No drama, just a lil note. πŸ“
  • -?, --help β€” show help about dropdb command line arguments, and exit. The classic β€œwait, how do I use this?” save. πŸ™ˆ

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. Path-coded, iykyk. 🌐
  • -p port, --port=port β€” specifies the TCP port or local Unix domain socket file extension on which the server is listening for connections. Port check, slay. πŸ”Œ
  • -U username, --username=username β€” user name to connect as. Main character login energy. πŸ‘‘
  • -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 β€œautomation said no humans today.” πŸ€–
  • -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 behavior. πŸ’…
  • --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. Big β€œwe need a staging area” energy. πŸ› οΈ

🌈 ENVIRONMENT 🌈

  • PGHOST, PGPORT, PGUSER β€” default connection parameters. The trio that handles where and who. 🌟
  • PG_COLOR β€” specifies whether to use color in diagnostic messages. Possible values are always, auto, and never. Choose your aesthetic. 🎨

This utility, like most other PostgreSQL utilities, also uses the environment variables supported by libpq (see Section 33.14). ✨

🩺 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. Basically: check the server, check the defaults, check the vibes. 🫢

πŸ“ 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 πŸ‘‘


πŸ’– that’s the whole page: dropdb, straight from PostgreSQL 13.23 documentation, dated 2025, DROPDB(1) and out. slay responsibly, bestie πŸ’–

πŸ“¦ where this page comes from