DROP DATABASE

Use the DROP DATABASE command to drop a database. It also removes catalog entries for the database and deletes the directory that contains the data. The DROP DATABASE command cannot be undone. You cannot issue this command while you are connected to the target database.

Syntax

Syntax for the DROP DATABASE command:
DROP DATABASE <name>

Input

The DROP DATABASE command takes the following input:
Table 1. DROP DATABASE input
Input Description
<name> The name of the database to be dropped.

Outputs

The DROP DATABASE command has the following outputs:
Table 2. DROP DATABASE outputs
Output Description
DROP DATABASE The command was successful.
DROP DATABASE: cannot be executed on the currently open database You cannot be connected to the database that you are about to remove. Connect to any other database, and run the command again.
DROP DATABASE: may not be called in a transaction block You must finish the transaction in progress before you can call the command.
ERROR: Can't delete database - num object(s) depend on objects in it The database contains objects such as user-defined functions, user-defined aggregates, or stored procedures, which are dependencies for objects that are defined in other databases. Use the SELECT * FROM_v_depend query to identify the objects in other databases that depend on objects in the database that you want to drop. You must resolve all the dependencies by either dropping or altering those objects before you can drop the database.
ERROR: DROP DATABASE: Database "DB_NAME" has 269968 tables and/or sequences. Objects must be manually dropped until the number is less than 260000. The database contains more than 260,000 objects. You must manually drop objects in the database until the object number is below 260,000. You can then use the DROP DATABASE command to drop the database.

Privileges

You must be the admin user, the database owner, or your account must have the Delete privilege for the database or for the Database object class.

Usage

The following provides sample usage:
  • Drop the database emp:
    MYDB.SCH1(USER)=> DROP DATABASE emp;