DB2 Specific Working Titbits

We can find if a table needs to be reorged or not by using the following query.

db2 "select tabschema,tabname from SYSIBMADM.ADMINTABINFO where reorg_pending='Y'"

To get the information about the Table and Schema from the TBSSPACEID and TableID use the following SQL.

SELECT C.TABSCHEMA, C.TABNAME,
C.COLNAME
FROM SYSCAT.TABLES AS T,
SYSCAT.COLUMNS AS C
WHERE T.TBSPACEID = 3
AND T.TABLEID = 258
AND C.COLNO = 6
AND C.TABSCHEMA = T.TABSCHEMA
AND C.TABNAME = T.TABNAME


Selecting or Generating the Next Value for a particular Sequence in DB2.

For example say we have a sequece name PAYMENT_TABLE_SEQ,  and we want to check wheather this sequence is working or not we can do it by
the following SQL in DB2,

values(NEXTVAL FOR PAYMENT_TABLE_SEQ ) 


Using the above we can generate the next value for a particular Sequence and also make sure that the sequence is working


Comments

Popular posts from this blog

Converting Java Map to String

Invoking EJB deployed on a remote machine

Difference between volatile and synchronized