Search Articles

Showing posts with label DB2 Admin. Show all posts
Showing posts with label DB2 Admin. Show all posts

Top 50 Most Important DB2 Commands for Database Administrator

IBM Db2 is database software that can reliably handle multiple workloads. The latest version of Db2 is optimized to provide extreme performance while lowering costs.

Below are the most useful db2 admin commands:



Command
Description
db2cmd
Open DB2 Command line Tool
db2cc
Open DB2 Control Centre
db2start
Start Database Normaly
db2stop
Stop Database Normaly
db2stop force
Stop Database forcely
db2 force application all
Close all applications that uses DB2 Database.
db2level
Display DB2 version and fix pack level
db6level
Display DB2 Client Version
db2 terminate
Close the database connection
db2_kill -all
Kill a hanged instance
db2licm -l
View license information
db2 connect to <db2sid>
Establish connection to an instance
db2 list tablespaces show detail
Displays table space information
db2 get dbm cfg
Display configuration parameter of database manager.
db2 get db cfg for <db2 sid>
Display configuration parameter of an instance
db2 update dbm cfg using <parameter_name> <new value>
Change value of a database manager configuration parameter.
db2 update db cfg for <db2 sid> using <parameter_name> <new value>
Change value of a instance configuration parameter.
db2 drop database <target db2sid>
Delete and instance
db2 activate db <dbsid>
Activate Database
db2 deactivate <dbsid>
Deactivate an active database
db2 rollforward db <SID> to end of logs
Apply all pending logs
db2 rollforward db <db2sid> query status
Display rollforward status
db2 backup database <sid> to “disk:\location”
Take an offline backup to specified location
db2 list utilities show detail
Display Database backup status
db2 restore db <sid> from “disk:\path” replace history file
Restore database from a backup image
Read more ...

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.

Read more ...

CONTACT

Name

Email *

Message *