DB2 10.5 for Linux, UNIX, and Windows

DROP DATABASE command

Deletes the database contents and log files for the database, uncatalogs the database, and deletes the database subdirectory.

Scope

By default, this command affects all database partitions that are listed in the db2nodes.cfg file.

Authorization

One of the following authorities:
  • SYSADM
  • SYSCTRL

Required connection

Instance. An explicit attachment is not required. If the database is listed as remote, an instance attachment to the remote database partition server is established for the duration of the command.

Command syntax

Read syntax diagramSkip visual syntax diagram
>>-DROP--+-DATABASE-+--database-alias--+-------------------+---><
         '-DB-------'                  '-AT DBPARTITIONNUM-'   

Command parameters

DATABASE database-alias
Specifies the alias of the database to be dropped. The database must be cataloged in the system database directory.
AT DBPARTITIONNUM
Specifies that the database is to be deleted only on the database partition that issued the DROP DATABASE command. This parameter is used by utilities supplied with IBM DB2 Warehouse, can be used in partitioned database environments, and is not intended for general use. Improper use of this parameter can cause inconsistencies in the system, so it should only be used with caution.

Examples

The following example deletes the database referenced by the database alias SAMPLE:
   db2 drop database sample

Usage notes

DROP DATABASE deletes all user data and log files, as well as any backup and restore history for the database. If the log files are needed for a rollforward recovery after a restore operation, or the backup history required to restore the database, these files should be saved before issuing this command.

When you use the DROP DATABASE command, archived log files for the dropped database are not affected. You must manually move archived log files from the log archive path. If you do not move these log files, future database recovery operations that use the same archive log path might fail.

The database must not be in use; all users must be disconnected database before the database can be dropped.

To be dropped, a database must be cataloged in the system database directory. Only the specified database alias is removed from the system database directory. If other aliases with the same database name exist, their entries remain. If the database being dropped is the last entry in the local database directory, the local database directory is deleted automatically.

If DROP DATABASE is issued from a remote client (or from a different instance on the same machine), the specified alias is removed from the client's system database directory. The corresponding database name is removed from the server's system database directory.

You must migrate databases to DB2® Version 10.5 before dropping a database. If you drop a database before migrating it, the operation fails (SQL5035N).