DROPDB(1)

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

πŸ’… dropdb β€” bestie, it's giving database deletion realness

okay so this is dropdb, and it lives in the PostgreSQL 17.11 Documentation, manual section 1. She's a little utility with a big job and honestly? She ate. Let's get into it πŸŽ€


✨ NAME ✨

dropdb β€” remove a PostgreSQL database πŸ—‘οΈπŸ’–


πŸ¦‹ SYNOPSIS πŸ¦‹

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

🌸 DESCRIPTION 🌸

So dropdb destroys an existing PostgreSQL database. Like, gone gone. Periodt. πŸ’€

The user who runs this command must be a database superuser or the owner of the database β€” no exceptions, no cap, the vibe check is strict here πŸ‘‘

dropdb is basically a cute little wrapper around the SQL command DROP DATABASE. And fr fr, there's no effective difference between dropping databases via this utility versus via any other method for accessing the server. Same energy, same outcome πŸ’«


πŸ’… 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, the one you're sending away 🫢
  • -e, --echo β€” echoes the commands that dropdb generates and sends to the server. so you can see exactly what she's saying behind your back πŸ‘€
  • -f, --force β€” attempts 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 "clear the room before the drama" 😭
  • -i, --interactive β€” issues a verification prompt before doing anything destructive. she asks first, like a respectful icon πŸ’…
  • -V, --version β€” prints the dropdb version and exits. quick little flex, then she's out πŸšͺ
  • --if-exists β€” do not throw an error if the database doesn't exist. a notice is issued in this case. lowkey the chill option 🌈
  • -?, --help β€” shows help about dropdb command line arguments, and exits. ask and she shall answer πŸŽ€

πŸ”Œ connection parameter era πŸ”Œ

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's used as the directory for the Unix domain socket. slashes = socket energy, 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. be someone else for a sec, iconic behavior 🎭
  • -w, --no-password β€” never issue a password prompt. if the server requires password authentication and a password isn't 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 πŸ€–
  • -W, --password β€” forces 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's worth typing -W to avoid the extra connection attempt. efficiency queen behavior, honestly ⚑

  • --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 doesn't 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. she's flexible but she picks favorites πŸ’œ

🌈 ENVIRONMENT 🌈

  • PGHOST
  • PGPORT
  • PGUSER

default connection parameters 🫢

  • PG_COLOR β€” specifies whether to use color in diagnostic messages. possible values are always, auto and never. yes bestie, the errors can be pretty too 🎨

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 🧠✨


πŸ“ 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 she warns you first? respectful. communicative. a whole queen πŸ‘‘πŸ˜­


πŸ”₯ SEE ALSO πŸ”₯

createdb(1), DROP DATABASE (DROP_DATABASE(7))

⚠️ real talk tho: this command destroys a database. the -i flag exists for a reason, bestie. use it. love yourself. πŸ’–

and that's the whole page, diva ✨ β€” this was PostgreSQL 17.11, dated 2026, and that's the tea on dropdb. now go forth and be careful with your databases πŸ§šβ€β™€οΈπŸŽ€πŸ’œ

πŸ“¦ where this page comes from