DB2 Table and Index Commands

Look at columns and data types of a table
=>db2 describe table schema.tabelename
Look at one column's data type.
=>db2 "describe select from schema.tablename"
Look at indexes on a table:
=>db2 describe indexes for table schema.tablename
Export data to a file in ixf format:
  • =>db2 export to tablename.ixf of ixf messages tablename.txt select * from SCHEMA.TABNAME
Import data from an ixf file:
  • =>db2 import from filename.ixf of ixf messages tablename.txt insert into SCHEMA.TABNAME
Import using Load which is faster (doesn't check constraints) and NONRECOVERABLE doesn't log anything.
  • =>db2 load from filename.ixf of ixf insert into SCHEMA.TABNAME nonrecoverable;
Build a file to set integrity on all tables that are in set integrity pending state.
=>db2 "select 'set integrity for '||tabschema||'.'||tabname ||' immediate checked;' from syscat.tables where type = 'T' and status = 'C'" > file.out

Popular posts from this blog

Jython Script Examples

Skip fields during duplication