There have been many big features added to PostgreSQL 13, like Parallel Vacuum, de-duplication of indexes, etc., and a complete list can be found at PostgreSQL 13 release notes. Along with the big features, there are also small ones added, including dropdb –force.

Dropdb –force

A new command-line option is added to dropdb command, and a similar SQL option “FORCE” is also added in DROP DATABASE. Using the option -f or –force with dropdb command or FORCE with DROP DATABASE to drop the database, it will terminate all existing connections with the database. Similarly, DROP DATABASE FORCE will do the same.

In the first terminal, create a test database and a database test, and connect to the database.

In the second terminal, try to drop the test database and you will get the error message that the test database is being used by another user.

Now try the same command with the FORCE option. You will see that the database is dropped successfully.

Note: you can also use the command line dropdb test -f.

The session on the first terminal will be terminated.

Looking for more info on other PostgreSQL 13 changes? Check out Ibrar’s previous post, Postgresql_fdw Authentication Changes in PostgreSQL 13!