PostgreSQL 13 New Feature – Drop Database

Drop Database in PostgreSQL 13

Warning: The information provided here is based on unsupported development version of PostgreSQL 13.

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.

Here, from PostgreSQL v13 on wards you have an option to drop database forcefully even if an external session is connected.

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.

To drop a database use “DROP DATABASE” command.

Example.,

[postgres@testdb ~]$ psql -d p13
psql (13devel)
Type “help” for help.

Let us try that.

[postgres@testdb bin]$ psql
psql (13devel)
Type “help” for help.

To create a database in PostgreSQL 13 we use below command

To drop a database in PostgreSQL 13 we use below command

Syntax: drop database p13 with (force);

Thank you for giving your valuable time to read the above information. I hope the content served your purpose in reaching out to the blog.
Suggestions for improvement of the blog are highly appreciable. Please contact us for any information/suggestions/feedback.

If you want to be updated with all our articles

please follow us on Facebook Twitter
Please subscribe to our newsletter.

Leave a Reply