Languages
[Edit]
EN

PostgreSQL - Drop database

0 points
Created by:
Amir-Hashempur
607

In this article, we would like to show you how to DROP database in PostgreSQL.

Quick solution:

DROP DATABASE "database_name";

DROP DATABASE example

In this example, we will drop database named diraskDB.

Query:

DROP DATABASE "diraskDB";

DROP DATABASE IF EXISTS example

You can optionally add IF EXISTS statement, so if the database doesn't exist you won't get an error.

Query:

DROP DATABASE IF EXISTS "diraskDB";

Popular error

If you try to drop database that doesn't exist with DROP DATABASE query you will get an error:

PostgreSQL - SQL Error: Can't drop database 'database_name'
PostgreSQL - SQL Error: Can't drop database 'database_name'

If you try to DROP DATABASE IF EXISTS you will get a warning instead:

PostgreSQL - Note: Can't drop database 'database_name'
PostgreSQL - Note: Can't drop database 'database_name'
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

Cross technology - Drop database

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join