INFORMATICS

The Best

Using DROP DATABASE

Inicio desactivadoInicio desactivadoInicio desactivadoInicio desactivadoInicio desactivado
 

Using DROP DATABASE

This command 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. This command cannot be executed while you or anyone else is connected to the target database (connect to postgres or any other database to issue this command).

Syntax

The syntax for DROP DATABASE is given below −

DROP DATABASE [ IF EXISTS ] name

Parameters

The table lists the parameters with their descriptions.

S. No.Parameter & Description
1

IF EXISTS

 

Do not throw an error if the database does not exist. A notice is issued in this case.

2

name

The name of the database to remove.

Example

The following is a simple example, which will delete testdb from your PostgreSQL schema −

postgres=# DROP DATABASE testdb;

 

Search