URL's----------------------------------------------Videos by Raul F.Chong
http://www.channeldb2.com/group/db2oncampus#TechVideos
http://www.channeldb2.com/group/db2chatwiththelab
http://www.db2util.com/tuning/cache-hit-ratio-db2/
www7b.boulder.ibm.com/dmdd
http://www.toadworld.com/platforms/ibmdb2/w/wiki/7243.tablespace-tuning.aspx
BOOKS&ALL
http://public.dhe.ibm.com/ps/products/db2/info/vr95/pdf/en_US/
------------------------------------------
Details of AIX test machine:IP : 9.184.232.165User name : trainingPassword :aix1234
uninstall direcotry for v9.5 :/opt/IBM/db2/V9.5/instance
for installing license: db2licm -a /db2/db2inst1fs/db2ese_c.lic
for checking lincese db2licm -l
db2evmon -path /db2/db2inst1fs/db2dump/mybrnchdeadlock/
event monitor /db2/db2inst1fs/db2dump/mybrnchdeadlock
db2 "select distinct (TABSCHEMA) from syscat.tables"db2 describe syscat.tablesdb2pd -db (database) -tablespaces
db2 "get snapshot for dynamic sql on <DBNAME>"
db2 "get snapshot for all DATABASES" > outit.txt
db2 "get snapshot for dynamic sql on wppaupdb" > dynamicwpp
db2 "get snapshot for tablespaces on sample"
db2 "get snapshot for dynamic sql on smb_db" > dynamicsmb.txt
-----------------------------------------------------------------
Some Notes on SNAPSHOT:# Using the GET SNAPSHOT command#Selecting from a snapshot table function
Use the Snapshot Monitor with the get snapshot command (discussed in Section 17.8, TheSnapshot Monitor) to get an accurate measurement of the number of transactions per minute ifthe database is already operational.
Specify the priority for the selected database on the Priority page (see Figure 17.8). If thedatabase is optimized for fast transaction processing, the database may take longer to recover inthe event of an error. If the database is optimized for fast recovery time, transaction performancenormally will be slower. If it is equally important to optimize both, choose to balance theoptimization of the two.---------------------------------
The GET SNAPSHOT command captures the requested snapshot information and writes theinformation to the screen or to an ASCII file.
You then need to examine the output of the snapshot for the information that you are looking for.
Since you access the snapshot table functions using SQL, you can select only the data you are interested in,
store the data quickly into a history table, and so on.
To get a snapshot for all of the activity on the database sample, you would issue the command:
# Using the GET SNAPSHOT commanddb2 "get snapshot for all on sample" | more
#Selecting from a snapshot table functionTo get the same information using the snapshot table function, you would use the statement:
db2 "SELECT * FROM TABLE(SNAPSHOT_DATABASE('SAMPLE',-1 )) as SNAPSHOT_DATABASE" > output.txt
You can then set the average number of active applications for the database sample based on thesnapshot information as follows:
db2 update db cfg for sample using avg_appls 10
-----------------------------------------------------------------
db2 autoconfigure apply none
Start an instance =================
db2start
Stopping the instance =======================
db2stop
Connect to the database ===========================UPDATE COMMAND OPTIONS USING {options ...}
db2 connect to databasename
to know the database size
db2 "call get_dbsize_info (?,?,?,0)" | more
db2 connect reset
db2 list db directory
db2 list node directory
db2 get connection state
db2ilist
db2 list applications show detail | grep -i lock
db2 get snapshot for locks for application applid "<ID>"
db2 get instance
db2 list tablespaces show detail
db2 list tablespace containers for id show detail
to know the table space Occupency and utilization from tthe following SQL
----------------------------------------by quirying the following
$db2"SELECT * FROM SYSIBMADM.TBSP_UTILIZATION">"C:\dout\SYSIBMADM.out"
gives the following information to monitor the tablespaces.--------------------------------------------------------------
C:\Program Files\IBM\SQLLIB\BIN>db2 "SELECT substr(TBSP_NAME,1,15),substr(TBSP_STATE,1,15),TBSP_NUM_CONTAINERS,TBSP_UTILIZATION_PERCENT FROM SYSIBMADM.TBSP_UTILIZATION" > "C:\dout\SADM5.out"
---------------------------------
If we want to monitor only one tablespace with the name 'MYDMS2'
$db2 select substr(TBSP_NAME,1,15),substr(TBSP_STATE,1,15),TBSP_NUM_CONTAINERS,TBSP_UTILIZATION_PERCENT FROM SYSIBMADM.TBSP_UTILIZATION WHERE TBSAP_NAME='MYDMS2'
___________________________________________________________________________________________________
SNAPSHOT_TIMESTAMP, TBSP_ID,TBSP_NAME,TBSP_TYPE,TBSP_CONTENT_TYPE,TBSP_CREATE_TIME,TBSP_STATE,
TBSP_TOTAL_SIZE_KB,TBSP_USABLE_SIZE_KB,TBSP_USED_SIZE_KB,TBSP_FREE_SIZE_KB,TBSP_UTILIZATION_PERCENT,
TBSP_TOTAL_PAGES,TBSP_USABLE_PAGES,TBSP_USED_PAGES,TBSP_FREE_PAGES,TBSP_PAGE_TOP,TBSP_PAGE_SIZE,
TBSP_EXTENT_SIZE, TBSP_PREFETCH_SIZE,TBSP_MAX_SIZE,TBSP_INCREASE_SIZE,TBSP_INCREASE_SIZE_PERCENT,
TBSP_LAST_RESIZE_TIME,TBSP_LAST_RESIZE_FAILED,TBSP_USING_AUTO_STORAGE,TBSP_AUTO_RESIZE_ENABLED,DBPGNAME
TBSP_NUM_CONTAINERS REMARKS DBPARTITIONNUM-------------------------- -------------------- ----------------------------- ---------- ----------------- -------------------------- -------------------- --------------------------------------------------------
db2 list applications show detail
db2 force applications all
db2 deactivate db dbname
db2 activate db dbname
db2 list bufferpools
db2 get snapshot for all bufferpools >bpsnap.txt
db2 "get snapshot for all bufferpools" > "C:\Documents and settings\krishna\Desktop\dbout\bpsnap.txt"
db2 "get snapshot for all bufferpools" > "C:\Documents and Settings\krishna\Desktop\dbout\bpsnap1.txt"
===================================================================================================To find the Memory / Cache Hit Ratio/ Bufferpool Hit Ratios On !The cache hit ratio is one of the indicators used for tuning tasks. It Measures the percentage of hits in memory, specifically in the bufferpools (each of them).
To get the cache hit ratio for each buffer pool configured to run this query:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
db2 "SELECT SUBSTR(DB_NAME,1,8) AS DB_NAME, SUBSTR(BP_NAME,1,14) AS BP_NAME,TOTAL_HIT_RATIO_PERCENT, DATA_HIT_RATIO_PERCENT,INDEX_HIT_RATIO_PERCENT FROM SYSIBMADM.BP_HITRATIO ORDER BY DBPARTITIONNUM"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
This query shows the ratio for each cache buffer, separating between the ratio obtained with data blocks and index blocks.
If the value of this ratio is above 90%, it�s ok, if not: may indicate a problem with the memory size assigned to the instance.
==========================================================================================
C:\Program Files (x86)\IBM\SQLLIB\BIN>db2 "SELECT AVERAGE_EXECUTION_TIME_S as TIME_SECONDS, NUM_EXECUTIONS as EXECUTIONS, STMT_TEXT as TEXT FROM SYSIBMADM.TOP_DYNAMIC_SQL WHERE STMT_TEXT like 'SELECT%' ORDER BY AVERAGE_EXECUTION_TIME_S DESC FETCH FIRST 10 ROWS ONLY"
C:\Program Files (x86)\IBM\SQLLIB\BIN>db2 "SELECT AVERAGE_EXECUTION_TIME_S as TIME_SECONDS, NUM_EXECUTIONS as EXECUTIONS, STMT_TEXT as TEXT FROMSYSIBMADM.TOP_DYNAMIC_SQL WHERE STMT_TEXT like 'SELECT%' ORDER BY AVERAGE_EXECUTION_TIME_S DESC FETCH FIRST 10 ROWS ONLY" > sql10.txt
===========================================================================================db2 list nodegroups
db2 LIST DBPARTITIONNUMS
db2 LIST DB PARTITION GROUPS
LIST PACKEGES/TABLES [FOR [USER/ALL/SCHEMA]] [SHOW DETAIL]
LIST UTILITIES
LIST TABLESPACES
LIST TABLESPACE CONTAINERS FOR <tablespace id> [SHOW DETAIL]
Alter tablespace tbs1 add (file �path� 200M)
Alter tablespace tbs1 extend (file '/conts/cont0' 1000)
Alter tablespace tbs1 extend (all 1000)
Alter tablespace tbs1 resize (all 1000)
Alter tablespace tbs1 reduce (all 100)
Alter tablespace TS1 add (file 'cont2' 2000, FILE 'cont3' 2000) add (file 'cont4' 2000) extend (file 'cont0' 100) resize (file 'cont1' 3000
get snapshot for tablespaces on sample
update dbm cfg using dt_mon_bufpool on
get dbm monitor switches
get monitor switches
db2 update monitor switches using lock on
Drop a database: =================Db2 drop database sample
Monitoring backups========================
db2 list history backup all for db dlexicon
From TSm========
Checking full backups-----------------------
db2adutl query db dbname full
checking Incremental and Full backups-------------------------------------
db2adutl query db dbname
Taking backup in local systems================================
-------------------------------------------------------
Taking the Backup and Checking the status
$db2 "backup db sample to 'C:\Documents and Settings\krishna\Desktop\dbout'"
To validate if a taken backup is correct and valid to be restored,
$db2ckbkp "C:\Documents and Settings\krishna\Desktop\dbout\SAMPLE.0.DB2.NODE0000.CATN0000.20130623083248.001"
---------------------------------------------------------------------
db2 backup database contract to /db2/db8co2tfs/backup with 2 buffers buffer 1024
db2 backup database contract online to /db2/db8co2tfs/backup with 2 buffers buffer 1024
db2 "BACKUP DATABASE CIRATSDB to /database/backups WITHOUT PROMPTING COMPRESS"
Taking backup using Tivoli storage manager(TSM)================================================
db2 backup database contract use tsm with 2 buffers buffer 1024
db2 backup database contract online use tsm with 2 buffers buffer 1024
Backup for tablespace======================
Online using tsm=================
db2 backup database deb_wc tablespace(TAB8K) online use tsm
Offline using tsm=================
db2 backup database deb_wc tablespace(TAB8K) use tsm
Cataloging remote database===========================
db2 catalog tcpip node diblstge remote dmiw11a.btv.ibm.com server 50091
db2 catalog database diblstge at node diblstge
Change perssions and ownership===============================
chmod 774 diblrept.prodb2 "select 'delete from bcmmstr.'||tabname||';'from syscat.tables where tabschema='BCMMSTR' and type='T'"
chown db2as diblrept.pro
Restore=========
db2 restore db debwcbau from /database/db_backups/debwcbau/20070721_1 into debwcbau WITHOUT ROLLING FORWARDdb2 "RESTORE DATABASE dlexicon FROM /db2/db2inst1fs TAKEN AT 20100601053731 INTO dlexicon WITHOUT PROMPTING"db2 "rollforward db bcmds stop"Redirect restore===============
db2 restore db contract from /db2/db8co2tfs replace existing redirect without rolling forward
db2 list tables for schema SYSIBM
SQL2523W Warning! Restoring to an existing database that is different from the database on the backup image, but have matching names. The target database will be overwritten by the backup version. The Roll-forward recovery logs associated with the target database will be deleted.
SQL1277N Restore has detected that one or more table space containers areinaccessible, or has set their state to 'storage must be defined'.DB20000I The RESTORE DATABASE command completed successfully.
db2 list tablespaces show detaildb2 list tablespace containers for id show detail
db2 "set tablespace containers for 0 using(file'/db2/db2inst1fs/db2inst1/NODE0000/DLEXICON/T0000000/C0000000.CAT' 16384)"db2 "set tablespace containers for 1 using('/db2/db2inst1fs/db2inst1/NODE0000/DLEXICON/T0000001/C0000000.TMP')"db2 "set tablespace containers for 2 using(file'/db2/db2inst1fs/db2inst1/NODE0000/DLEXICON/T0000002/C0000000.LRG' 8192)"db2 "set tablespace containers for 3 using(file'/db2/db2inst1fs/db2inst1/NODE0000/DLEXICON/T0000003/C0000000.LRG' 8192)"db2 "set tablespace containers for 4 using('/db2/db2inst1fs/db2inst1/NODE0000/DLEXICON/T0000004/C0000000.UTM')"db2 restore database dlexicon continue
db2 "set tablespace containers for 4 using(file'/db2/db8co2tsfs/tbspace2/dtbs2.dat' 10000)"db2 "set tablespace containers for 5 using(file'/db2/db8co2tsfs/tbspace3/dtbs3.dat' 1000)"
db2 restore database contract continue
db2 restore database contract complete========================================================
snapshots==========
db2 get snapshot for application agentid idnumber
db2 get snapshot for all APPLICATIONS global
db2 get snapshot for database on deb_wcdb2 get snapshot for applications on deb_wcdb2 get snapshot for tables on dlexicondb2 get snapshot for locks on dlexicon | pgdb2 get snapshot for tablespaces on ciratst | pgdb2 get snapshot for all on dlexicon | pgdb2 "get snapshot for lock on db dlexicon > out.outqueries=========
db2expln -d CONTRACT -o q1.out -f q1 -z @ -t -graph
db2advis -d <dbname> -i <file with sql statement>
Export ,import and load========================
db2 "export to file.ixf of ixf select * from schema.table"
db2 "import from file.ixf of ixf insert into schema.table"
db2 load from file.ixf of ixf replace into schema.table nonrecoverable
db2 EXPORT TO 'C:\Documents and Settings\BACKUP\data1' OF DEL MESSAGES 'C:\Documents and Settings\BACKUP\log1' SELECT * FROM KRISHNA.ACT
Runstats==========
db2 "runstats on table lexicon.temp_emp_upld with distribution and detailed indexes all"db2 "runstats on table lexicon.emp_mstr with distribution and detailed indexes all"
db2 runstats on table KRISHNA.EMPPROJACT with distribution and detailed indexes all
Reorgs=======db2 REORGCHK UPDATE STATISTICS ON TABLE adw.table
db2 REORGCHK current STATISTICS ON TABLE adw.table
db2 reorg indexes all for table ADW.TRAN allow write access
db2 reorg table ADW.TRAN select TABSCHEMA, TABNAME from SYSIBMADM.ADMINTABINFO where REORG_PENDING = 'Y'
db2move============================On source system:
� Create appropriate subdirectory
� run db2move <dbname> export
On target system
� Create appropriate subdirectory
� ftp all files to target system
� run db2move <db2name> import
db2look=========
db2look -d sample1 -m -l -a -x -e -f
db2look �d <dbname> -e �z <schema> -t tablename-o ouputfile
to check the size of a db=========================
db2 "call get_dbsize_info(?,?,?,0)"
to increase the filessystem size================================
chfs -a size=+10G <filesystem_name> this will increment the fs size by 1Gb
To find the privileges of a user ID=====================================================
db2 "select * from syscat.tabauth where GRANTEE = 'CIRATEST' and TABNAME in ('ACT_HIST_ATTACH','ACTIVITY_HISTORY','RECORDS')"
Grant statements for all the objects in a schema=================================================
db2 -x "select 'GRANT SELECT, INSERT, UPDATE, DELETE on ' || ltrim(rtrim(tabschema)) || '.' || ltrim(rtrim(tabname)) || ' to dlexicon;' from syscat.tables where tabschema = 'LEXICON'" > USER_GRANT_EDGE_OMFEG.SQLdb2 "GRANT SELECT on CIRATSDB.ACT_HIST_ATTACH TO CIRATEST"db2 "GRANT SELECT on CIRATSDB.ACTIVITY_HISTORY TO CIRATEST"db2 "GRANT SELECT on CIRATSDB.RECORDS TO CIRATEST"
script to prepare and execute the grants on the tables in a schema===================================================================
#!/bin/shDB_NAME=IBMEDGEdb2 connect to $DB_NAME
db2 -v "select substr(TABLE_SCHEMA ||'.'|| TABLE_NAME,1,50) AS TABLE_NAME from sysibm.tables where table_catalog = 'IBMEDGE' and TABLE_SCHEMA = 'EDGE' and TABLE_TYPE in ('VIEW', 'BASE TABLE', 'ALIAS' )" > out1
cat out1 | while read DDdo export TABLE=`echo $DD | awk '{print $1;}'`
db2 -x "GRANT SELECT ON ${TABLE} TO GROUP report" > grants.out# db2 -v "GRANT SELECT ON ${TABLE} TO GROUP hrlms2t"done#rm out1db2 disconnect $DB_NAME
To check if a table is in checkpending state============================================
db2 "select tabname from syscat.tables where STATUS='C'"
if a table is in checkpending state, then==========================================
db2 "SET INTEGRITY FOR <TABLE NAME> IMMEDIATE CHECKED"
To get the isolation level for a Database==========================================
db2 "select current isolation from sysibm.sysdummy1"
To get the list of Event Monitors created in a Database========================================================
db2 "select * from SYSCAT.EVENTMONITORS"
To get the DB AUTHORIZATIONS ==========================================================
db2 "select * from syscat.DBAUTH"
===============================================================
db2advis -d ciratst -n ciratsdb -i /db2/db8sr549/repos/db2advis.in -t 5
db2advis -d database name -w workload name-s statement -i filename -a userid -passwd password-l disk limit -t maxadvisetime
--------------------------------------------------------
ACTIVATE DATABASEActivates the specified database and starts up all necessary database services, so that the database is available for connection and use by any application.
Syntax ACTIVATE DATABASE / DB <db-alias> [USER <uname> USING <pwd>]
ARCHIVE LOGCloses and truncates the active log file for a recoverable database.
Syntax:ARCHIVE LOG FOR DATABASE/DB [USER <username> USING <password>
BACKUP DATABASECreates a backup copy of a database or a table space.
Syntax:BACKUP DATABASE <dbname> [USER <username> USING <password>] [TABLESPACE <tbspname>] [ [ONLINE INCREMENTAL ]/[INCREMENTAL DELTA] ] [ WITH <num-buffers> BUFFERS] [BUFFER <buffer-size>] [PARALLELISM n] [WITHOUT PROMPTING]
CATALOG DATABASEStores database location information in the system database directory. The database can be located either on the local workstation or on a remote node.
Syntax:CATALOG DATABASE <dbname> [as <alias>] [ ON <path> at NODE <nodename> ] [AUTHENTICATION [ SERVER ] [ CLIENT ] ]
CATALOG TCPIP NODEAdds a Transmission Control Protocol/Internet Protocol (TCP/IP) node entry to the node directory. The TCP/IP communications protocol is used to access the remote node. The CATALOG TCPIP NODE command is run on a client.
Syntax:CATALOG TCPIP NODE <nodename> [ REMOTE <hostname> SERVER <servicename> ]
CHANGE ISOLATION LEVELChanges the way that DB2 isolates data from other processes while a database is being accessed.
Syntax:CHANGE ISOLATION TO CS/NC/RR/RS/UR
CREATE DATABASEThe CREATE DATABASE command initializes a new database with an optional user-defined collating sequence, 9 creates the three initial table spaces, creates the system tables, and allocates the recovery log file. 9 When you initialize a new database, you can specify the AUTOCONFIGURE option to 9 display and optionally apply the initial values for the buffer pool size, 9 database and database manager parameters.
Syntax:CREATE DATABASE <dbname> [ON <path> DBPATH ON <path>] [ALIAS <dbalias>] [PAGESIZE <integer> / PAGESIZE 4096] [CATALOG TABLESPACE [ MANAGED BY [SYSTEM]/DATABASE [USING FILE/DEVICE 'container string' <numberofpages>] EXTENTSIZE <number of pages> [PREFETCH SIZE <number of pages> AUTORESIZE NO/YES INCREASESIZE <integer> PERCENT MAXSIZE <integer>] ] ]
DEACTIVATE DATABASE Stops the specified database.
Syntax:DEACTIVATE DATABASE/DB <dbname> [USER <username> USING <password>]
DESCRIBEThis command: ? Displays the output SQLDA information about a SELECT or CALL statement ? Displays columns of a table or a view ? Displays indexes of a table or a view
Syntax:DESCRIBE OUTPUT SELECT <statement>/CALL <statement> / TABLE <tablename> / INDEXES FOR TABLE <tablename> [SHOW DETAIL] DETACHRemoves the logical DBMS instance attachment, and terminates the physical communication connection if there are no other logical connections using this layer.
Syntax:DETACH
DROP DATABASEDeletes the database contents and all log files for the database, uncatalogs the database, and deletes the database subdirectory.
Syntax:DROP DATABASE <dbalias>
FORCE APPLICATION Forces local or remote users or applications off the system to allow for maintenance on a server.
Syntax:FORCE APPLICATION ALL
GET AUTHORIZATIONSReports the authorities of the current user from values found in the database configuration file and the authorization system catalog view (SYSCAT.DBAUTH).
Syntax:GET AUTHORIZATIONS
GET CONNECTION STATEDisplays the connection state. Possible states are: ? Connectable and connected ? Connectable and unconnected ? Unconnectable and connected ? Implicitly connectable (if implicit connect is available).
Syntax:GET CONNECTION STATE
GET DATABASE CONFIGURATIONReturns the values of individual entries in a specific database configuration file.
Syntax:GET DATABASE CONFIGURATION/CONFIG/CFG [FOR DATABASE/DB] [SHOW DETAIL]
GET DATABASE MANAGER CONFIGURATIONReturns the values of individual entries in the database manager configuration file.
Syntax:GET DATABASE MANAGER CONFIGURATION [SHOW DETAIL]
GET DATABASE MONITOR SWITCHESDisplays the status of the database system monitor switches. Monitor switches instruct the database system manager to collect database activity information. Each application using the database system monitor interface has its own set of monitor switches.
Syntax:GET DATABASE MONITOR SWITCHES
GET INSTANCEReturns the value of the DB2INSTANCE environment variable.
Syntax:GET INSTANCE
GET MONITOR SWITCHESDisplays the status of the database system monitor switches for the current session. Monitor switches instruct the database system manager to collect database activity information.
Syntax:GET MONITOR SWITCHES
GET SNAPSHOTCollects status information and formats the output for the user. The information returned represents a snapshot of the database manager operational status at the time the command was issued.
Syntax:GET SNAPSHOT FOR DATABASE MANAGER/DBM [ALL DATABASES/ APPLICATIONS/ BUFFERPOOLS/ REMOTE_DATABASES/REMOTE_APPLICATIONS]
HISTORYDisplays the history of commands run within a CLP interactive mode session.
Syntax:HISTORY [[REVERSE] <num>]
INSPECT: INSPECT allows you to inspect tables paces & tables for their architectural integrity while your database remains online. The inspection operation checks whether the structures of table objects & table
spaces are valid or not.
Syntax:db2 INSPECT CHECK <DATABASE / TABLESPACE NAME tbsp-name / TABLE NAME tb-name [SCHEMA NAME sch-name]> RESULTS [KEEP] <filename>
To view the contents of the data file use the db2inspf utility. Steps:1. db2 connect to sample2. db2 INSPECT TABLE NAME Emp RESULTS KEEP emp.txt (emp.txt is created in C:\IBM\SQLLIB\DB2)3. Now go to the path where the data file has been created.4. db2inspf <datafile> <outfile> <-e / -s>Data file � I/P file (binary) Out file � O/P file (text) �e � Errors only �s � Summary only 5. The O/P file is also created at C:\IBM\SQLLIB\DB2
LIST ACTIVE DATABASES:Displays a subset of the information listed by the GET SNAPSHOT FOR ALL DATABASES command. It lists all the active databases. Syntax:db2 LIST ACTIVE DATABASES
LIST APPLICATIONS:Displays to the standard output, the various applications running at that instance of time.
Syntax:db2 LIST APPLICATIONS [FOR DATABASE / DB <db-alias>] [SHOW DETAIL]
LIST COMMAND OPTIONS:Lists the current settings for the environment variables
Syntax:db2 LIST COMMAND OPTIONS
LIST DB PARTITION GROUPS:Lists the available database partition groups. There are three database partition groups created when a database is created, regardless of whether or not the database is partitioned: IBMCATGROUP, IBMDEFAULTGROUP and IBMTEMPGROUP.
Syntax:db2 LIST DB PARTITION GROUPS
DATABASE PARTITION GROUP----------------------------IBMCATGROUPIBMDEFAULTGROUP
2 record(s) selected.
LIST DBPARTITIONNUMS:Lists all database partitions associated with the current database.
Syntax:db2 LIST DBPARTITIONNUMSDATABASE PARTITION NUMBER--------------------------------------- 0
LIST DRDA INDOUBT:Provides a list of transactions that are indoubt between DRDA requesters and DRDA serversBefore issuing the LIST DRDA INDOUBT TRANSACTIONS command, the application process must be connected to the DB2 sync point manager (SPM) instance
Syntax:Db2 LIST DRDA INDOUBT TRANSACTIONS [WITH PROMPTING]
Steps:1. Get the value of spm_name parameter using �db2 get dbm cfg�.2. db2 connect to <spm_name>3. db2 LIST DRDA INDOUBT TRANSACTIONS
.LIST HISTORYLists entries in the history file. The history file contains a record of recovery and administrative events. Recovery events include full database and table space level backup, incremental backup, restore, and rollforward operations.
Syntax:LIST HISTORY BACKUP / ROLLFORWARD / DROPPED TABLE / LOAD / CREATE TABLESPACE/ALTER TABLESPACE/RENAME TABLESPACE/REORG/ARCHIVELOGALL[FOR DATABASE/DB <dbname>]
LIST INDOUBT TRANSACTIONSProvides a list of transactions that are indoubt. The user can interactively commit, roll back, or forget the indoubt transactions.
Syntax:LIST INDOUBT TRANSACTIONS [WITH PROMPTING]
LIST NODE DIRECTORYLists the contents of the node directory.
Syntax:LIST NODE DIRECTORY [SHOW DETAIL]
LIST PACKAGES/TABLESLists packages or tables associated with the current database.
Syntax:LIST PACKEGES/TABLES [FOR [USER/ALL/SCHEMA]] [SHOW DETAIL]
LIST TABLESPACE CONTAINERSLists containers for the specified table space.
Syntax:LIST TABLESPACE CONTAINERS FOR <tablespace id> [SHOW DETAIL]
LIST TABLESPACESLists table spaces for the current database.
Syntax:LIST TABLESPACES
LIST UTILITIESDisplays to standard output the list of active utilities on the instance. The description of each utility can include attributes such as start time, description, throttling priority (if applicable), as well as progress monitoring information (if applicable).
Syntax:LIST UTILITIES [SHOW DETAIL]
LOAD QUERYChecks the status of a load operation during processing and returns the table state. If a load is not processing, then the table state alone is returned
Syntax:LOAD QUERY TABLE <tablename> TO <local mag file> [NOSUMMARY/SUMMARY ONLY] [SHOW DETAIL]
MIGRATE DATABASEConverts previous versions of DB2 databases to current formats.
Syntax:MIGRATE DATABASE/DB <dbalias> [USER <username>] [USING <password>]
PINGTests the network response time of the underlying connectivity between a client and a connected database server.
Syntax:PING <dbalias> [ <number of times>]
PRUNE HISTORY/LOGFILEUsed to delete entries from the recovery history file, or to delete log files from the active log file path. Syntax:PRUNE HISTORY <timestamp> [WITH FORCE OPTION AND DELETE]/ LOGFILE PRIOR TO <logfilename>
QUERY CLIENTReturns current connection settings for an application process. Syntax:QUERY CLIENT
QUIESCEForces all users off the specified instance and database and puts it into a quiesced mode. In quiesced mode, users cannot connect from outside of the database engine
Syntax:QUIESCE DATABASE/DB [IMMEDIATE] [DEFER WITH TIMEOUT <minutes>] [FORCE CONNECTIONS]
QUIESCE INSTANCE <instancename> USER <username> GROUP <groupname> [IMMEDIATE] [DEFER WITH TIMEOUT <minutes>] [FORCE CONNECTIONS]
QUIESCE TABLESPACES FOR TABLE Quiesces table spaces for a table. There are three valid quiesce modes: share, intent to update, and exclusive. There are three possible states resulting from the quiesce function: QUIESCED SHARE, QUIESCED UPDATE, and QUIESCED EXCLUSIVE.
Syntax:QUIESCE TABLESPACES FOR TABLE <tablename> [SHARE/EXLUSIVE/INTENT YO UPDATE]
QUITExits the command line processor interactive input mode and returns to the operating system command prompt
Syntax:QUIT REBINDAllows the user to recreate a package stored in the database without the need for a bind file.
Syntax:REBIND PACKAGE <pkgname> [VERSION <version name>]
RECOVER DATABASERestores and rolls forward a database to a particular point in time or to the end of the logs.
Syntax:RECOVER DATABASE/DB <source dbalias> [TO END OF LOGS ] USER <username> USING <password> [USING HISTORY FILE <history file clause>]
REORG INDEXES/TABLEReorganizes an index or a table. The index option reorganizes all indexes defined on a table by rebuilding the index data into unfragmented,
Syntax;REORG TABLE <tbname> [INDEX <indexname> ALLOW NO/READ/WRITE ACCESS] / INDEXES ALL FOR TABLE <tbname> [ALLOW NO/READ/WRITE ACCESS]
REORGCHKCalculates statistics on the database to determine if tables or indexes, or both, need to be reorganized or cleaned up.
Syntax:REORGCHK [UPDATE STASTISTICS/CURRENT STATISTICS] ON TABLE USER/SYSTEM/ALL/<tbname>
RESTART DATABASERestarts a database that has been abnormally terminated and left in an inconsistent state. At the successful completion of RESTART DATABASE, the application remains connected to the database if the user has CONNECT privilege.
Syntax:RESTART DATABASE <dbalias> USER <username> USING <password> [DROP PENDING TABLESPACES]
ROLLFORWARD DATABASERecovers a database by applying transactions recorded in the database log files. Invoked after a database or a table space backup image has been restored, or if any table spaces have been taken offline by the database due to a media error.
Syntax:ROLLFORWARD DATABASE /DB <dbname> USER <username> USING <password> COMPLETE/STOP [TO END OF LOGS AND COMPLETE]
RUNSTATSUpdates statistics about the physical characteristics of a table and the associated indexes. These characteristics include number of records, number of pages, and average record length.
Syntax:RUNSTATS ON TABLE <tbname> [WITH DISTRIBUTION ON COLUMNS( colname1,colname2)]/ [FOR INDEXES ALL/<indexname1, indexname2>]
SET TABLESPACE CONTAINERSA redirected restore is a restore in which the set of table space containers for the restored database is different from the set of containers for the original database at the time the backup was done. This command permits the addition, change, or removal of table space containers for a database that is to be restored
Syntax:SET TABLESPACE CONTAINERS FOR <tablespace id> USING <path 'container string'>
START DATABASE MANAGERStarts the current database manager instance background |processes on a single database partition or on all the database partitions defined in a |multi-partitioned database environment.
Syntax:START DATABASE MANAGER/DBM [REMOTE INSTANCE <instancename> <remote options>] [ADMIN MODE USER <username> GROUP <groupname>]
START HADRStarts HADR operations for a database.
Syntax:START DATABASE ON DATABASE/DB <dbalias> [USER <username> USING <password>]AS PRIMARY/STANDBY [BY FORCE]
STOP DATABASE MANAGERStops the current database manager instance. Unless explicitly stopped, the database manager continues to be active. This command does not stop the database manager instance if any applications are connected to databases.
Syntax:STOP DATABASE MANAGER/DB MANAGER/DBM [PROFILE]
STOP HADRStops HADR operations for a database.
Syntax:STOP HADR ON DATABASE/DB <dbalias> [USER <username> USING <password>]
TAKEOVER HADR Instructs an HADR standby database to take over as the new HADR primary database 7 for the HADR pair.
Syntax:TAKEOVER HADR ON DATABASE <dbalias> [USER <username> USING <password>] BY FORCE
TERMINATEExplicitly terminates the command line processor's back-end process.
Syntax:TERMINATE
UNCATALOG DATABASEDeletes a database entry from the system database directory.
Syntax:UNCATALOG DATABASE <dbname>
UNCATALOG DCS DATABASE Deletes an entry from the Database Connection Services (DCS) directory.
Syntax:UNCATALOG DCS DATABASE <dbalias>
UNCATALOG NODEDeletes an entry from the node directory.
Syntax:UNCATALOG NODE <nodename>
UNQUIESCERestores user access to instances or databases which have been quiesced for maintenance or other reasons. UNQUIESCE restores user access without necessitating a shutdown and database restart.
Syntax:UNQUIESCE DATABASE/INSTANCE <instance name>
UPDATE DATABASE/DB CONFIGURATIONModifies individual entries in a specific database configuration file. A database configuration file resides on every node on which the database has been created.
Syntax:UPDATE DATABASE/DB CONFIGURATION FOR <dbalias> USING <config keyword value> [IMMEDIATE/DEFERRED]
UPDATE DATABASE MANAGER CONFIGURATIONModifies individual entries in the database manager configuration file.
Syntax:UPDATE DATABASE MANAGER/DBM CONFIGURATION FOR <dbalias> USING <config keyword value> [IMMEDIATE/DEFERRED]
UPDATE HEALTH NOTIFICATION CONTACT LISTUpdates the contact list for notification about health alerts issued by an instance.
Syntax:UPDATE HEALTH NOTIFICATION CONTACT LIST ADD/DROP CONTACTGROUP <name>
UPDATE HISTORY FILEUpdates the location, device type, or comment in a history file entry.
Syntax:UPDATE HISTORY FILE FOR <object part> WITH <eid> LOCATION <new location>/COMMENT <new comment>/STATUS <new status>
Syntax:UPDATE LDAP NODE <nodename> HOSTNAME <hostname>SVCENAME <svcename> NNAME <nname> NETWORK <net_id>[USER <username> PASSWORD <password>]
UPDATE MONITOR SWITCHESTurns one or more database monitor recording switches on or off. When the database manager starts, the settings of the six switches are determined by the dft_mon database manager configuration parameter.
Syntax:UPDATE MONITOR SWITCHES USING <switch name> ON/OFF
-------------------------
catalog tcpip node <node name> remote <servername> server <port no.>;catalog dcs database <dbname> as <local dbname>;catalog database <dbname> as <local dbname> at node <node name> authentication dcs;
db2set -alldb2set db2comm=tcpip
cat /etc/services
ftp -i servernamemput *.*
=============Simhachalam Kolli *Contractor*: db2 "GRANT CONNECT ON DATABASE TO USER dlexicon"db2 "GRANT IMPLICIT_SCHEMA ON DATABASE TO USER SANJAY"11:45:14 AM: Simhachalam Kolli *Contractor*: db2 "SELECT SUBSTR(GRANTOR, 1, 10) AS GRANTOR, SUBSTR(GRANTEE, 1, 10) AS GRANTEE, GRANTEETYPE, SUBSTR(TABSCHEMA ||'.'|| TABNAME, 1, 30) AS TABLE_NAME, CONTROLAUTH, ALTERAUTH, DELETEAUTH, INDEXAUTH, INSERTAUTH, SELECTAUTH, REFAUTH, UPDATEAUTH FROM SYSCAT.TABAUTH"11:47:05 AM: Simhachalam Kolli *Contractor*: db2 "select GRANTOR,GRANTORTYPE,GRANTEE,GRANTEETYPE,CONNECTAUTH from SYSCAT.DBAUTH"
db2 "GRANT DBADM ON DATABASE TO USER DLEXICON"
db2 "REVOKE DBADM ON DATABASE FROM USER DLEXICON"passwd -x 999999 <username>
db2 "load from /dev/null of del terminate into tabname"
select * from sysibm.SYSTABAUTH WHERE ttname='emp_mstr'
----------------b2inst1/passw0rd4:32:26 PM: [email protected]: command used for ur instance
installation steps:update db cfg for wppaupdb using logarchmeth1 disk:\TSM\
mklv -t jfs2 -y db2inst1lv -e'x' rootvg 10
crfs -v jfs2 -d db2inst1lv -m /db2/db2inst1lv -A'yes' -p'rw' -t'no' -a frag='4096' -a nbpi='4096' -a bf=true -a compress='no' -a ag='64'
crfs -v jfs2 -d db2inst1lv -m /db2/db2inst1fs -A'yes' -p'rw' -t'no' -a size=1G -a vix=yes
mount /db2/db2inst1fs
mkgroup db2adm1
mkuser pgrp=db2adm1 groups=db2adm1 home=/db2/db2inst1fs db2inst1
mkgroup db2fadm1
mkuser pgrp=db2fadm1 groups=db2fadm1 home=/home/db2fenc1 db2fenc1
mkgroup dasadm1
mkuser pgrp=dasadm1 groups=dasadm1 home=/home/dasusr1 dasusr1
./db2icrt -u db2fenc1 db2inst1
db2 list tablespaces show detail | grep -i name$ db2 list tablespaces show detail | grep -i state
db2 list tablespaces show detail | grep -ip BCMSTG_PM_WFL2_IX db2 LIST TABLESPACE CONTAINERS FOR 29 SHOW DETAIL
db2 "ALTER TABLESPACE BCMSTG_PM_WFL2_IX SWITCH ONLINE"
db2 "ALTER TABLESPACE BCMSTG_PM_WFL2_IX EXTEND (ALL 100 M)"------------------------------------------------------------------------------------------------------------------------TO genarate DDLS thr DB2 CLP
db2look -d WPPAUPDB -t PROMOTIONAL_PRICE -a -e -x -c ;
-----------------------------------------------------------------------
ACTIVATE DATABASE GET/UPDATE DB CFG RECONCILEADD CONTACT GET/UPDATE DBM CFG RECOVERADD CONTACTGROUP GET DBM MONITOR SWITCHES REDISTRIBUTE DB PARTITIONADD DATALINKS MANAGER GET DESCRIPTION FOR HEALTH REFRESH LDAPADD DBPARTITIONNUM GET NOTIFICATION LIST REGISTERARCHIVE LOG GET HEALTH SNAPSHOT REORG INDEXES/TABLEATTACH GET INSTANCE REORGCHKAUTOCONFIGURE GET MONITOR SWITCHES RESET ADMIN CFGBACKUP DATABASE GET RECOMMENDATIONS RESET ALERT CFGBIND GET ROUTINE RESET DB CFGCATALOG APPC NODE GET SNAPSHOT RESET DBM CFGCATALOG APPN NODE HELP RESET MONITORCATALOG DATABASE HISTORY RESTART DATABASECATALOG DCS DATABASE IMPORT RESTORE DATABASECATALOG LDAP DATABASE INITIALIZE TAPE REWIND TAPECATALOG LDAP NODE INSPECT ROLLFORWARD DATABASECATALOG LOCAL NODE LIST ACTIVE DATABASES RUNCMDCATALOG NPIPE NODE LIST APPLICATIONS RUNSTATSCATALOG NETBIOS NODE LIST COMMAND OPTIONS SET CLIENTCATALOG ODBC DATA SOURCE LIST DATABASE DIRECTORY SET RUNTIME DEGREECATALOG TCPIP NODE LIST DB PARTITION GROUPS SET TABLESPACE CONTAINERSCHANGE DATABASE COMMENT LIST DATALINKS MANAGERS SET TAPE POSITIONCHANGE ISOLATION LEVEL LIST DBPARTITIONNUMS SET UTIL_IMPACT_PRIORITYCREATE DATABASE LIST DCS APPLICATIONS SET WRITECREATE TOOLS CATALOG LIST DCS DIRECTORY START DATABASE MANAGERDEACTIVATE DATABASE LIST DRDA INDOUBT START HADRDEREGISTER LIST HISTORY STOP DATABASE MANAGERDESCRIBE LIST INDOUBT TRANSACTIONS STOP HADRDETACH LIST NODE DIRECTORY TAKEOVERDROP CONTACT LIST ODBC DATA SOURCES TERMINATEDROP CONTACTGROUP LIST PACKAGES/TABLES UNCATALOG DATABASEDROP DATABASE LIST TABLESPACE CONTAINERS UNCATALOG DCS DATABASEDROP DATALINKS MANAGER LIST TABLESPACES UNCATALOG LDAP DATABASEDROP DBPARTITIONNUM LIST UTILITIES UNCATALOG LDAP NODE
DROP TOOLS CATALOG LOAD UNCATALOG NODEECHO LOAD QUERY UNCATALOG ODBC DATAEDIT MIGRATE DATABASE UNQUIESCE DATABASEEXPORT PING UNQUIESCE INSTANCEFORCE APPLICATION PREP/PRECOMPILE UPDATE ALERT CFGGET/UPDATE ADMIN CFG PRUNE HISTORY/LOGFILE UPDATE COMMAND OPTIONSGET ALERT CFG PUT ROUTINE UPDATE CONTACTGET AUTHORIZATIONS QUERY CLIENT UPDATE CONTACTGROUPGET/UPDATE CLI CFG QUIESCE DATABASE UPDATE NOTIFICATION LISTGET CONNECTION STATE QUIESCE INSTANCE UPDATE HISTORYGET CONTACTGROUP QUIESCE TABLESPACES UPDATE LDAP NODEGET CONTACTGROUPS QUIT UPDATE MONITOR SWITCHES
For further help: ? db2-command - help for specified command ? OPTIONS - help for all command options ? HELP - help for reading help screensThe preceding three options can be run as db2 <option> from an OS prompt.
!db2ic - DB2 Information Center (Windows only)
TO RESET THE db PARAMETORS TO THE DEFAULT VALUES
$ db2 reset db cfg for sample
To update the parametor
$db2 update dbm cfg using <DIAGPATH> <C:\krishna\Desktop........> or </home/krishna/Desktop/....>
=====================================================DB2 DIAG PATH ALLOCATION IN DBM CFG BY DEFAULT THE diag path won't be avilable
C:\Program Files\IBM\SQLLIB\BIN>db2 get dbm cfg | find " DIAG"
C:\Program Files\IBM\SQLLIB\BIN>db2 get dbm cfg | find "DIAG" Diagnostic error capture level (DIAGLEVEL) = 3 Diagnostic data directory path (DIAGPATH) = (By Default It's empty)
Try directly without creating the folder diagpath in C:\ Drive
C:\Program Files\IBM\SQLLIB\BIN>db2 "UPDATE DATABASE MANAGER CONFIGURATION USING DIAGPATH c:\db2diagpath"SQL5137N The entry in the database manager configuration file for thediagnostic directory path (diagpath) is invalid.
After creating the folder diagpath in C:\ Drive apply the following command.
C:\Program Files\IBM\SQLLIB\BIN>db2 "UPDATE DATABASE MANAGER CONFIGURATION USING DIAGPATH c:\db2diagpath"
DB20000I The UPDATE DATABASE MANAGER CONFIGURATION command completedsuccessfully.+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C:\Program Files\IBM\SQLLIB\BIN>
C:\Program Files\IBM\SQLLIB\BIN>db2 "describe table SYSCAT.TABLESPACES"
C:\Program Files\IBM\SQLLIB\BIN>db2"select TBSPACE,BUFFERPOOLID FROM SYSCAT.TABLESPACES" | more
C:\Program Files\IBM\SQLLIB\BIN>db2 list tables for schema SYSCAT
TO KNOW THE AUTHORITIES:
C:\Program Files\IBM\SQLLIB\BIN>db2 describe table SYSCAT.TABAUTH
C:\Program Files\IBM\SQLLIB\BIN>db2 "select * FROM SYSCAT.TABAUTH where GRANTEE='KRISHNA' " > krish7.txt
C:\Program Files\IBM\SQLLIB\BIN>db2 "select * FROM SYSSTAT.TABLES WHERE TABSCHEMA='KRISHNA' AND TABNAME='EMPPROJACT'" > krish8.txt
Top Related