Help Center > > Developer Guide> SQL Reference> SQL Syntax> DROP DATABASE

DROP DATABASE

Updated at:Mar 13, 2020 GMT+08:00

Function

DROP DATABASE deletes a database.

Precautions

  • Only the owner of a database or a system administrator has the permission to run the DROP DATABASE command.
  • DROP DATABASE does not take effect for the three preinstalled system databases (POSTGRES, TEMPLATE0, and TEMPLATE1) because they are protected. To check databases in the current service, run the \l command of gsql.
  • This command cannot be run while the database to be deleted is associated with a user. You can check the current database connections in the v$session view.
  • DROP DATABASE cannot be run inside a transaction block.
  • If DROP DATABASE fails to be run and is rolled back, run DROP DATABASE IF EXISTS.

DROP DATABASE cannot be undone.

Syntax

1
DROP DATABASE [ IF EXISTS ] database_name ;

Parameter Description

  • IF EXISTS

    Sends a notice instead of an error if the specified database does not exist.

  • database_name

    Specifies the name of the database to be deleted.

    Value range: A string indicating an existing database name.

Examples

See Examples in CREATE DATABASE.

Helpful Links

CREATE DATABASE

Did you find this page helpful?

Submit successfully!

Thank you for your feedback. Your feedback helps make our documentation better.

Failed to submit the feedback. Please try again later.

Which of the following issues have you encountered?







Please complete at least one feedback item.

Content most length 200 character

Content is empty.

OK Cancel