Deletes the database contents and log files for the database, uncatalogs the database, and deletes the database subdirectory.
By default, this command affects all database partitions that are listed in the db2nodes.cfg file.
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.
>>-DROP--+-DATABASE-+--database-alias--+-------------------+--->< '-DB-------' '-AT DBPARTITIONNUM-'
db2 drop database sample
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).