понедельник, 1 июня 2015 г.

DB2 export data tables from remote database

If you have IBM DB2 client and you have to move data from remote source database to local target database then you can use db2 move utility.

First, catalog the node:
1) db2 catalog tcpip node <node_name> remote <server_name> server <port_number>
2) db2 terminate

Second, catalog the database:
3) db2 catalog db <remote_db_name> as <local_alias_db_name> at node <node_name>
4) db2 terminate

Export data:
db2move <db_name> export -sn <schema_name> -aw -u <login> -p <password>

You can move schemas or given tables. See help for db2move.

Before importing tables data in existent tables you should turn off identity constraint else import process fail:
db2 alter table <table_name> alter column <column_name_with_identity> drop identity

Import data:
db2move <db_name> import -u <login> -p <password>

After import restore identity constraint:
db2 ALTER TABLE <table_name> ALTER COLUMN <column_name_with_identity> SET GENERATED AS IDENTITY ( START WITH <count_the_number_yourself> INCREMENT BY 1)

To uncatalog database and node:
   db2 uncatalog database <alias-name>
   db2 uncatalog node <node_name>

Комментариев нет:

Отправить комментарий