Wednesday, December 22, 2010

TQ-DB2

-----------to know description for table

select * from syscat.tables where tabname='BFTB_JOB'

-----------------to know timings of the table

select current_timestamp from sysibm.sysdummy1;

db2 connect to U11S9B15 user using db2isnt1

db2 set current schema = bankfusion

db2 terminate

------------show db details

list db2 utilities show detail

-------------To restart Db server

db2stop force

db2start

db2 terminate

db2 activate database UBP128N

--------

Db2 locktimeout:

db2 connect to u14s8b7

db2 get db cfg for u14s8b7 | grep LOCK

db2 update db cfg for u14s8b7 using LOCKTIMEOUT 15

----- to alter column size in db2

alter table bankfusion.BFTB_JOB alter column BFPARAMETERS set data type BLOB(5120)

---- db2 backup

db2 force applications all

db2 backup db UB15PF7 to directory_or_device

db2 restore db UB15PF7 from /ubperf/backups/BackUp_UB15PF7_EOM_MBT212_22july/ replace existing

---------to list databases

db2 list database directory

---------------current date updates in column

select * from table name where trunc(coulmn name)=trunc(current_date)

db back up

db2 backup db UB15PF3 to /ubpt01/backups/backup_UB15PF3_29Mar10_MBTBuild40

----to take import

db2 import from tab1.ixf of ixf messages tab1.msg REPLACE_CREATE into wasadmin.closeoff

db2 import from tab1.ixf of ixf messages tab1.msg REPLACE_CREATE into wasadmin.closeoff

db2 import from tab179.ixf of ixf messages tab179.msg insert into cbs.CBTB_BUSINESSEVENT

---to take export

db2move UB15PF7 export -tn BFTB_CONTENTIONCONTEXT,CLOSEOFF,UBTB_DELINQUENCYPROFILE,UBTB_GENERALPROVISION,UBTB_GENERALPROVISIONHIST,UBTB_GENPROVISIONTAG,UBTB_INTERESTACCRUALACCOUNTS

------------db2explain plan

db2expln -d UB15PF7 -z ";" -q "select * from cbs.cbtb_code where cbreference='CUSTOMERTYPE';" –g –t

--------------db2 get db cfg – for database level parameters

db2 get dbm cfg – for instance level parameters the below set of parameters specify the number of agents

Priority of agents (AGENTPRI) = SYSTEM

Agent pool size (NUM_POOLAGENTS) = AUTOMATIC(100)

Initial number of agents in pool (NUM_INITAGENTS) = 0

Max number of coordinating agents (MAX_COORDAGENTS) = AUTOMATIC(200)

Max number of client connections (MAX_CONNECTIONS) = AUTOMATIC(MAX_COORDAGENTS)

To update the parameters

db2 update dbm cfg using NUM_POOLAGENTS

To list the number of connections to a database

Connect to the database and issue the command

db2 list application show detail

------------Run this on the DB to get the list of tables created with the associated tablespaces-

select a.tabname, a.owner, DECODE(a.type, 'V', 'VIEW', (DECODE(a.type,'T','TABLE',a.type))) , b.TBSPACE

from syscat.tables a, syscat.tablespaces b

where tabschema in ('WASADMIN', 'BRANCH', 'BANKFUSION', 'CBS', 'DB2INST1', 'DB2PM', 'DMSTAGE', 'LOANORG', 'NULLID', 'SQLJ', 'SYSCAT', 'SYSFUN', 'SYSIBM', 'SYSIBMADM', 'SYSIBMINTERNAL', 'SYSIBMTS', 'SYSPROC', 'SYSPUBLIC', 'SYSSTAT', 'SYSTOOLS', 'UBINTERFACE' )

and a.TBSPACEID = b.TBSPACEID

order by TBSPACE

--------------------------------The main DB2 import modes include:

  • INSERT adds the input data to the table without changing any existing data.
  • INSERT_UPDATE adds new input data to the table, or updates existing rows with input data that has matching primary key values.
  • REPLACE deletes all existing data from the table (by truncating the data object) and then inserts the input data.
  • REPLACE_CREATE deletes all data from an existing table and then inserts the input data. If the table does not exist, this mode creates the table prior to inserting the input data. This mode is only valid with PC/IXF input files.

Further reference:

http://www.ibm.com/developerworks/data/library/techarticle/dm-0501melnyk/

----------------------statements for backing up tables

  • create table wasadmin.collateraldtlbackup like wasadmin.collateraldtl
  • insert into wasadmin.collateraldtlbackup select * from wasadmin.collateraldtl

Change table names as needed.

---------------------db2stop - Stop DB2 Command

Stops the current database manager instance.

db2stop can be executed as a system command or a CLP command.

Related reference

This topic can be found in: Command Reference.

No comments: