From 1379fd537f9fc7941c8acff8c879ce3636dbdb77 Mon Sep 17 00:00:00 2001 From: Amit Kapila Date: Tue, 12 Nov 2019 11:06:13 +0530 Subject: Introduce the 'force' option for the Drop Database command. This new option terminates the other sessions connected to the target database and then drop it. To terminate other sessions, the current user must have desired permissions (same as pg_terminate_backend()). We don't allow to terminate the sessions if prepared transactions, active logical replication slots or subscriptions are present in the target database. Author: Pavel Stehule with changes by me Reviewed-by: Dilip Kumar, Vignesh C, Ibrar Ahmed, Anthony Nowocien, Ryan Lambert and Amit Kapila Discussion: https://postgr.es/m/CAP_rwwmLJJbn70vLOZFpxGw3XD7nLB_7+NKz46H5EOO2k5H7OQ@mail.gmail.com --- doc/src/sgml/ref/drop_database.sgml | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/ref/drop_database.sgml b/doc/src/sgml/ref/drop_database.sgml index 3ac06c984a3..cef1b904219 100644 --- a/doc/src/sgml/ref/drop_database.sgml +++ b/doc/src/sgml/ref/drop_database.sgml @@ -21,7 +21,11 @@ PostgreSQL documentation -DROP DATABASE [ IF EXISTS ] name +DROP DATABASE [ IF EXISTS ] name [ [ WITH ] ( option [, ...] ) ] + +where option can be: + + FORCE @@ -32,9 +36,11 @@ DROP DATABASE [ IF EXISTS ] name 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. - Also, it cannot be executed while you or anyone else are connected - to the target database. (Connect to postgres or any - other database to issue this command.) + 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. @@ -64,6 +70,25 @@ DROP DATABASE [ IF EXISTS ] name + + + 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 will fail if the current user has no permissions to terminate other + connections. Required permissions are the same as with + pg_terminate_backend, described in + . This will also fail if we + are not able to terminate connections. + + + + -- cgit v1.2.3