DROP_DATABASE(7pg14)

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

🌸 NAME 🌸

DROP_DATABASE β€” remove a database. Hii bestie, welcome to the DROP_DATABASE(7) page from the PostgreSQL 14.24 Documentation πŸ’– β€” this is literally the β€œremove a database” manual, and yes, it goes exactly as hard as it sounds. πŸ’…

✨ SYNOPSIS ✨

Here’s the whole shape of it, no cap:

DROP DATABASE [ IF EXISTS ] name [ [ WITH ] ( option [, ...] ) ]

where option can be:

    FORCE

It’s giving short, iconic, and a little dangerous. πŸŽ€

πŸ’– DESCRIPTION πŸ’–

So DROP DATABASE drops a database. Like, actually drops it: it removes the catalog entries for the database and deletes the directory containing the data. 🫢

Only the database owner can execute it. Periodt. It cannot be executed while you’re connected to the target database β€” connect to postgres or any other database to issue this command. Also, if anyone else is connected to the target database, this command will fail unless you use the FORCE option described below.

DROP DATABASE cannot be undone. Use it with care! 😭πŸ”₯

πŸŽ€ PARAMETERS πŸŽ€

  • IF EXISTS β€” do not throw an error if the database does not exist. A notice is issued in this case. πŸ™ˆ
  • name β€” the name of the database to remove. Simple, iconic, to the point.
  • FORCE β€” attempt to terminate all existing connections to the target database. It doesn’t terminate if prepared transactions, active logical replication slots or subscriptions are present in the target database.

It terminates background worker connections and connections that the current user has permission to terminate with pg_terminate_backend, described in Section 9.27.2. If connections would remain, this command will fail. πŸ’€

🧚 NOTES 🧚

DROP DATABASE cannot be executed inside a transaction block. No cap.

This command cannot be executed while connected to the target database. Thus, it might be more convenient to use the program dropdb(1) instead, which is a wrapper around this command. Slay. ✨

🌈 COMPATIBILITY 🌈

There is no DROP DATABASE statement in the SQL standard. That’s it, that’s the compatibility update. 😌

πŸ¦‹ SEE ALSO πŸ¦‹

  • CREATE DATABASE (CREATE_DATABASE(7)) β€” the other half of the database lifecycle, bestie. πŸ¦‹

πŸ’– okay bye bestie β€” this was the DROP DATABASE(7) page from PostgreSQL 14.24, dated 2026. Now go forth and drop responsibly. πŸ’–

πŸ“¦ where this page comes from