db2 CONNECT TO "dbname"
db2stop //to stop instance
dbstart //to start instance
db2 list database directory // list all live databse
db2 CREATE DATABASE "database name"
db2 CONNECT RESET //disconect database but still run in
background
db2 terminate //disconect database
db2 list application
db2 "force application (application id)"
db2 force application all
db2 get db cfg for "database name"
db2 get dbm cfg //list all configuration of instance
db2 describe table "table name"
db2 select *from syscat.bufferpools //list all bufferpools connected to
databse
db2 list tablespaces show detail
db2 list active databases
db2 create bufferpool "buffer-name,size,etc"
db2 drop bufferpool "bufferpool-name"
db2licm -l // list database license
db2licm -a "path of licens" //add new license path
db2licm -r "name of license" // to remove current license
db2 update dbm cfg using DFTDB "path" //change path that databases save in
it
**online backup steps**:
db2 get db cfg for "database name"| grep LOGARCHMETH // check status
of archive logging
mkdir /home/db2inst1/online_backup
chown db2inst1:db2iadm1 /home/db2inst1/online_backup //use command if u
are not db2inst1 user
db2 update database configuration for "database name" using LOGARCHMETH1
'disk:/home/db2inst1/online_backup'
db2 force application all
db2 deactivate db "database name"
db2 backup database "database name" to /home/db2inst1/offline_backup
//offline backup reqiuer before online backup
db2 activate db "database"
db2 backup database "database"online to /home/db2inst1/online_backup/ compress
include logs //create online backup
** restore online backup **:
db2 terminate
db2 deactivate db "database name"
db2 list history backup all for "database name" //to know history backup and
timestamp for each database
db2 restore database "database name" from /home/db2inst1/online_backup taken at
"timestamp"
db2 rollforward db <db_name> to end of logs and stop
db2 activate db "database name"