DROP_DATABASE(7pg13)
π DROP_DATABASE(7) π
okay bestie, welcome to the DROP DATABASE(7) page from the PostgreSQL 13.23 Documentation β¨ this is the whole vibe: how to remove a database, and what to watch out for before you do it. no cap.
πΈ NAME πΈ
DROP_DATABASE β remove a database ποΈ
β¨ SYNOPSIS β¨
DROP DATABASE [ IF EXISTS ] name [ [ WITH ] ( option [, ...] ) ]
where option can be:
FORCE
π DESCRIPTION π
DROP DATABASE drops a database. it removes the catalog entries for the database and deletes the directory containing the data. it can only be executed by the database owner. it cannot be executed while you are 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! like, fr fr, this is not a drill π
π¦ PARAMETERS π¦
IF EXISTSβ do not throw an error if the database does not exist. a notice is issued in this case. lowkey polite β¨nameβ the name of the database to remove. yes, this is the actual target, bestie π―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.
this 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.
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. iconic little shortcut behavior π
β COMPATIBILITY β
there is no DROP DATABASE statement in the SQL standard. so yeah, this one is very much a PostgreSQL main character move π
π SEE ALSO π
CREATE DATABASE (CREATE_DATABASE(7))
and thatβs the whole page, bestie π«Ά stay hydrated, back up your stuff, and remember this was PostgreSQL 13.23 docs, dated 2025 β mwah ππ
π¦ where this page comes from
- opensuse-leap 16.0: postgresql13 13.23-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql13 13.23-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql13 13.23-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql13 13.23-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