Useful DB2 Commands

Among dozens of usefull db2 commands, these are several most usefull db2command, well at least commands that i use the most.

A Database Movement Tool Command. This tool facilitates the movement of large numbers of tables between DB2 databases located on workstations. The tool queries the system catalog tables for a particular database and compiles a list of all user tables. It then exports these tables in PC/IXF format. The PC/IXF files can be imported or loaded to another local DB2 database on the same system, or can be transferred to another workstation platform and imported or loaded to a DB2 database on that platform.

A Benchmark Tool Command. Reads SQL statements from either a flat file or standard input, dynamically prepares and describes the statements, and returns an answer set.

The RESTORE DATABASE command rebuilds a damaged or corrupted database that has been backed up using the DB2 backup utility. The restored database is in the same state that it was in when the backup copy was made. This utility can also overwrite a database with a different image or restore the backup copy to a new database.

Sample Command

db2move sample export

This will export all tables in the SAMPLE database; default values are used for all options.

db2move sample export -tc userid1,us*rid2 -tn tbname1,*tbname2

This will export all tables created by “userid1” or user IDs LIKE “us%rid2”, and with the name “tbname1” or table names LIKE “%tbname2”.

db2move sample export -tn *cust*

This will export all tables with the name “%cust%”.

db2move sample import -io replace -u userid -p password

This will import all tables in the SAMPLE database in REPLACE mode; the specified user ID and password will be used. Parameters for io can be one of INSERT, INSERT_UPDATE, REPLACE, CREATE, and REPLACE_CREATE.

restore db rcms2 from /data/tempdb taken at 20100324184458  into RCMS3 without rolling forward

Restore the DB to another name and with a specific timestamp.

db2batch -d CSS -f insertproduct.sql

This will execute insertproduct.sql

references :

Have Fun (@)

No Comments

Leave a Comment

Please be polite. We appreciate that.
Your email address will not be published and required fields are marked