Important DB2 Commands

=============================================================

Creating of DB2 Instance
[root@mercury instance]# cd /opt/ibm/db2/V9.1/instance
[root@mercury instance]# ./db2icrt -u db2fenc1 db2inst1

=============================================================

Delete DB2 Instance
[root@mercury instance]# cd /opt/ibm/db2/V9.1/instance
[root@mercury instance]# ./db2idrop db2inst1

=============================================================

List the Instance
[root@mercury instance]# cd /opt/ibm/db2/V9.1/instance
[root@mercury instance]# ./db2ilist

=============================================================

Start DB2 Instance
[db2inst1@mercury ~]$ db2start

=============================================================

Stop DB2 Instance
[db2inst1@mercury ~]$ db2stop

=============================================================

List DB2 Applications
[db2inst1@mercury ~]$ db2 list applications
[db2inst1@mercury ~]$ db2 list applications for database sample show detail
[db2inst1@mercury ~]$ db2 list applications for database sample show detail | grep -i “executing”
[db2inst1@mercury ~]$ db2 list applications for database sample show detail | grep -i “lock”

=============================================================

List DB2 TableSpace
[db2inst1@mercury ~]$ db2 list tablespaces
[db2inst1@mercury ~]$ db2 list tablespaces show detail

=============================================================

List DB2 Diagnostic Details
[db2inst1@mercury ~]$ db2pd -inst | head -2
[db2inst1@mercury ~]$ db2pd -osinfo

=============================================================

List DB2 History
[db2inst1@mercury ~]$db2 list history all for SAMPLE
[db2inst1@mercury ~]$db2 list history since 19980201 for sample
[db2inst1@mercury ~]$db2 list history backup containing userspace1 for sample
[db2inst1@mercury ~]$db2 list history dropped table all for db sample

=============================================================

List Active Databases
[db2inst1@mercury ~]$ db2 list active databases

=============================================================

Get DB2 Authorizations
[db2inst1@mercury ~]$ db2 get authorizations

=============================================================

List DB Directory
[db2inst1@mercury ~]$ db2 list db directory
[db2inst1@mercury ~]$ db2 list database directory
[db2inst1@mercury ~]$ db2 list database directory on /home/db2inst1

=============================================================

Db2 License Management
[db2inst1@mercury adm]$cd /home/db2inst1/sqllib/adm/
To view the Licenses
[db2inst1@mercury adm]$ ./db2licm -lFor compliance report
[db2inst1@mercury adm]$ ./db2licm -g /tmp/licences

To Remove the license
[db2inst1@mercury adm]$ ./db2licm -r

=============================================================

Display DB2 Version Info
[root@mercury instance]# db2level

=============================================================

DB2 Backup
Offline Backup:
[db2inst1@mercury adm]$ db2 backup db sampleOnline Backup:
[db2inst1@mercury dbbackup]$ backup db sample online to /databasebkp1, /databasebkp2

List recent backups
[db2inst1@mercury dbbackup]$ db2 list history backup all for sample

Check the integrity of a backup image
[db2inst1@mercury dbbackup]$ db2ckbkp SAMPLE.0.db2inst1.NODE0000.CATN0000.20110524073459.001

=============================================================

DB2 Restore
[db2inst1@mercury dbbackup]$ db2 restore db sample incremental automatic taken at 20110524091023

=============================================================

DB2 Size and Capacity
[db2inst1@mercury dbbackup]$ db2 ‘call get_dbsize_info(?,?,?,0)’

=============================================================

Connect and Disconnect from DB2 Instance
[db2inst1@mercury dbbackup]$ db2 CONNECT TO sample USER db2inst1 using password
[db2inst1@mercury dbbackup]$ db2 connect reset
[db2inst1@mercury dbbackup]$ db2 terminate

=============================================================

Create SAMPLE Db in DB2
[root@mercury instance]# cd /opt/ibm/db2/V9.1/instance
[db2inst1@mercury dbbackup]$ db2sampl

=============================================================

DB2 administration server
[root@mercury instance]# ./dascrt -u dasusr1

=============================================================

DB2 administration server Stop
[root@mercury instance]# ./db2icrt -u db2fenc1 db2inst1

=============================================================

DB2 administration server Start
[dasusr1@mercury ~]$ db2admin start

=============================================================

DB2 Fault Monitor
Enable Fault Monitor Coordinator
[root@mercury bin]# cd /opt/ibm/db2/V9.1/bin/
[root@mercury bin]# ./db2fmcu -u -p /opt/ibm/db2/V9.1/bin/db2fmcdStart up the fault monitor daemon
[root@mercury bin]# cd /opt/ibm/db2/V9.1/bin
[root@mercury bin]# ./db2fm -i db2inst1 -U

Start up the fault monitor service
[root@mercury bin]# cd /opt/ibm/db2/V9.1/bin
[root@mercury bin]# ./db2fm -i db2inst1 -u

Turn on the fault monitor for the instance
[root@mercury bin]# ./db2fm -i db2inst1 -f on

Verify the fault monitor state
[[db2inst1@mercury ~]$ db2fm -s -S

Verify the FMC Daemon state
[root@mercury bin]# ./db2fmcu

=============================================================

Stop the Fault Monitor Deamon
[root@mercury bin]# cd /opt/ibm/db2/V9.1/bin
[root@mercury bin]# ./db2fmcu -d

=============================================================

Lists the DB2 products
[db2inst1@mercury ~]$ db2ls
[db2inst1@mercury ~]$ db2ls -q -a -b /opt/ibm/db2/V9.1

=============================================================

List Database Configuration parameters
[db2inst1@mercury ~]$ db2 get db cfg

=============================================================

List Database Manager parameters
[db2inst1@mercury ~]$ db2 get dbm cfg

Leave a Reply

Your email address will not be published. Required fields are marked *