select open change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

Unsupported versions: 7.0 / 6.5 / 6.4
Historical version. PostgreSQL 6.4 reached end of support in October 2003. See the current manual for supported releases.

DROP DATABASE

Name

DROP DATABASE — Destroys an existing database
DROP DATABASE name
  

Inputs

name

The name of an existing database to remove.

Outputs

DESTROYDB

This message is returned if the command is successful.

WARN: destroydb: database "name" does not exist.

This message occurs if the specified database does not exist.

ERROR: destroydb cannot be executed on an open database

This message occurs if the specified database does not exist.

Description

DROP DATABASE removes the catalog entries for an existing database and deletes the directory containing the data. It can only be executed by the database administrator (See the CREATE DATABASE command for details).

Notes

DROP DATABASE statement is a Postgres language extension.

Tip: This query cannot be executed while connected to the target database. It is usually preferable to use the destroydb script instead.

Refer to the CREATE DATABASE statement for information on how to create a database.

Compatibility

SQL92

There is no DROP DATABASE in SQL92.

Report a documentation issue

Read the upstream documentation. For corrections, first check the current manual.