Search Articles

How to Drop DB2 database Installed on Linux

DB2 Drop database command deletes all its objects, containers, and associated files. The dropped database is removed (uncataloged) from the database directories. You cannot drop a database if someone is connected to it. You would need to force everyone off the database first.




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.


Below are the Step-by-Step process to drop DB2 Database


Step 1: 
Login to the db2 instance. Example in my case db2inst1


Step 2:
$ db2 force application all
DB20000I  The FORCE APPLICATION command completed successfully.
DB21024I  This command is asynchronous and may not be effective immediately.


Step 3:
$ db2 stop
SQL1064N  DB2STOP processing was successful.
SQL1064N  DB2STOP processing was successful.


Step 4:
$ db2start
0   0   SQL1063N  DB2START processing was successful.
SQL1063N  DB2START processing was successful.


Step 5: 
$ db2 drop database airsan    --Here airsan is database name or alias name.
SQL1032N  No start database manager command was issued.  SQLSTATE=57019


Step 6:
$ db2 connect to airsan
SQL1013N  The database alias name or database name "AIRSAN" could not be
found.  SQLSTATE=42705


Now we have dropped the database named AIRSAN. When you try to connect it will throw an error because we have dropped the database and now it is not in the catalog.

No comments:

Post a Comment

CONTACT

Name

Email *

Message *