Вы находитесь на странице: 1из 1

DB2 Commands a Cheat Sheet by Graeson Lewis

DB2 Software DB2 Objects DB2 Recovery


db2setup db2 “create db db1” db2 “update db cfg for db1 using trackmod yes”
db2_install db2 "activate db db1" db2 “update db cfg for db1 using logarchmeth1 recovery”
installFixPack -b db2dir db2 "deactivate db db1" db2 “update db cfg for db1 using logarchmeth2 userexit”
db2rspgn -i db2inst1 db2 "upgrade db db1" db2adutl query
db2setup -r file.rsp db2 “create tablespace ts1” db2adutl delete full taken at timestamp db db1
db2licm -l show detail db2 “create schema s1” db2ckbkp file
db2licm -a file.lic db2 “create table t1 (c1 int) in ts1” db2 "quiesce db immediate"
db2level db2 “create index i1 on t1(c1)” db2 "unquiesce db"
db2ls db2 "list db partition groups" db2 "backup db db1"
db2ls -q -b db2dir -a db2 "list tablespaces show detail" db2 “backup db db1 online include logs”
db2 "list tablespace containers for 0" db2 “backup db db1 use tsm compress”
db2 "list tables show detail" db2 “backup db db1 on all dbpartitionnums”
db2 "list packages" db2 “backup db db1 online incremental”
db2 “backup db db1 online incremental delta”
DB2 Instance db2 "list utilities show detail"
db2 “list history backup all for db1”
db2 "describe table t1"
db2start db2 "describe indexes for table t1" db2 “list history since timestamp for db db1”
db2stop db2 "describe output select * from t1" db2 “restore db db1 from /path”
db2icrt -u db2fenc1 db2inst1 db2look -d db1 -e -l -x -o file.sql db2 “restore db db1 into d1 taken at timestamp”
db2idrop db2inst1 db2advis -d db1 -s “select * from t1” db2 “restore db db1 replace existing redirect”
db2iupdt db2inst1 db2advis -d db1 -i file.sql db2 “set tablespace containers for 5 using (file ‘/data/c1’ 8192)”
db2iupgrade -u db2fenc1 db2inst1 db2 “restore db db1 continue”
db2ilist db2 “restore db db1 incremental automatic”
db2 "rollforward db db1 to end of logs"
db2 “rollforward db db1 to isotime”
DB2 Configuration db2 “rollforward db db1 complete”
db2 "recover db db1"
DB2 Connectivity db2iauto -on db2inst1 db2 "recover db db1 to isotime"
db2set -all db2 "prune history 20091231"
db2 "connect to db1" db2set -lr
db2 “connect to db1 user u using p” db2set db2options=+c
db2 "connect reset" db2set DB2COMM=tcpip
db2set -null DB2COMM
db2 "list node directory"
db2 "get dbm cfg show detail" DB2 Maintenance
db2 "catalog tcpip node n1 remote r1
server 50000" db2 “update dbm cfg using
db2 "reorgchk update statistics on table all"
db2 "uncatalog node n1" intra_parallel no”
db2 “reorgchk update statistics on schema s1”
db2 "list db directory" db2 "get db cfg for db1 show detail"
db2 “reorgchk update statistics on table system”
db2 "catalog db db1 at node n1" db2 “update db cfg for db1 using self_tuning_mem on”
db2 "reorg table t1"
db2 "uncatalog db db1" db2 "autoconfigure using mem_percent 80 apply db
db2 “reorg table t1 inplace”
db2 "terminate" and dbm”
db2 “reorg index i1 for table t1”
db2 “reorg indexes all for t1
db2pd -d db1 -reorgs
db2 “runstats on table t1 and indexes all”
DB2 SQL & DML db2 "runstats on table t1 with distribution and detailed indexes all"
db2 “runstats on table t1 with distribution on key columns
db2 "select * from t1 where c1 = 1" and sampled detailed indexes all”
db2 "insert into t1 (id, name) values (1, 'abc')" db2pd -runstats
db2 "update t1 set c1 = 'xyz' where id = 1" db2look -d db1 -m -o file.sql
db2 "delete from t1 where c1 = 1" db2 "bind @db2ubind.lst blocking all grant public"
db2 “commit” db2 "bind @db2cli.lst blocking all grant public"
db2 “rollback” db2rbind db1 -l logfile all

DB2 High Availability DB2 Monitoring & Tuning DB2 Security


db2 "start hadr on db db1 as primary" db2 "list applications show detail" db2 “create database db1 restrictive”
db2 "start hadr on db db1 as standby" db2mtrk -i -d -a -v -r 10 db2 “update dbm cfg using authentication server_encrypt”
db2 "stop hadr on db db1" db2top -d db1 db2 “update dbm cfg using sysadm_group g1”
db2 "takeover hadr on db db1" db2pd -db db1 -database db2 “update dbm cfg using sysctrl_group g2”
db2 “update db cfg for db1 using logindexbuild on” db2pd -db db1 -bufferpools db2 “update dbm cfg using sysmaint_group g3”
db2 “update db cfg for db1 using hadr_sync_mode db2pd -db db1 -tablespaces db2 “grant dbadm on database to g4”
nearsync” db2 “get dbm monitor switches” db2 “grant load on database to g5”
db2pd -db db1 -hadr db2 “update monitor switches using bufferpool on” db2 “grant select on table t1 to user user1”
db2set DB2_HADR_BUF_SIZE = 65536 db2 “reset monitors all” db2 “revoke connect on database from public”
db2 “update db cfg for db1 using logfilsiz 65536” db2 “get snapshot for database manager” db2 “revoke use of tablespace ts1 from public”
db2 “update alternate server for db db1 using db2 “get snapshot for database on db1” db2 “revoke select on table syscat.dbauth from public”
hostname h1 port 50000” db2 “get snapshot for bufferpools on db1” db2 “update dbm cfg using audit_buf_sz 8192”
db2 “get snapshot for tablespaces on db db1” db2audit describe
db2 “get snapshot for tables on db db1” db2audit configure scope checking status failure
db2 “get snapshot for applications on db1” errortype normal
db2 “get snapshot for dynamic sql on db1”
DB2 Troubleshooting db2 “get snapshot for locks on db1”
db2audit start
db2audit extract delasc delimiter , category checking
db2 "force applications all" db2 “call sysproc.am_get_lock_chns(15,?)” database db1 status failure
db2 "force application (12345)" db2batch -d db1 -f file.sql db2audit prune data yyyymmddhh
db2diag -g -d db1 -l severe
db2diag -lastrecords 5
db2diag -rc
db2support . -d db1 -c
db2dart db1 /ts DB2 Development
db2dart db1 /t
db2 -td@ -svf file.sql
db2dart db1 /ddel
create procedure sp1(in p1 int) language sql begin select * from t1 where c1 = p1; end@
db2 "inspect check table name t1 schema s1
create trigger g1 after insert on t1 for each row update t2 set c1 = c1 + 1@
indexdata results keep t1.out"
create function f1 (x double) returns double language sql return sin(x)/cos(x)@
db2 “inspect rowcompestimate table name t1
create table t1 (id int, c1 char(1), c2 char(1)) organize by (c1, c2)@
schema foo results f1.out”

DB2 Data Movement Notes GRAESON LEWIS


db2move db1 export • System commands used for installing, managing, and updating software are graeson@gmail.com
db2move db1 import path dependant (i.e. /cdrom/db2setup, /opt/ibm/db2/V9.7/instance/db2icrt) ceevee.com/graeson
db2move db1 copy -sn s1 -co target_db db1 • Before issuing DB2 commands or invoking the Command Line Processor, you linkedin.com/in/graeson
db2 "export to t1.del of del select * from t1” must source a db2profile (i.e. . /home/db2inst1/sqllib/db2profile) graeson.wordpress.com
db2 “import from t1.del of del insert into t1” • DB2 commands can be grouped into scripts and executed from the command
db2 "load from t1.del of del replace into t1” line using db2 -tvf filename.clp -o filename.log

Copyright 2011 © Graeson Lewis

Вам также может понравиться