Question

I have two IBM DB2 servers at separate remote locations.

I need to copy data from several tables on one database on the first server to another database in the second server.

Previously I've used the IBM data studio tool to export the data and Load Replace it into the other table in the second server.

I am in need of a way to automate this. Probably through command line shell scripts.

How can I accomplish this?

Was it helpful?

Solution

You can always use the "data movement" tools included in DB2. Using EXPORT in one side (source server), and then IMPORT or LOAD in the other (target server). However, you have to take care of the transportation. I mean, you have to copy the data from one server to the other (via SCP, FTP, etc) and you can automate all of that.

Also, you can use a new tool called INGEST. It is a client tool, and this tool will put the data in the target tables of the remote server. This means that the source server will be the client of the remote server (you can catalog a remote database, in a database server).

Finally, you can create a federation between the two server (and this is my favorite). This means that in a database (for example in the target server) you present the tables of the other (source) server. This allows you to do queries between local and remote tables, and this will also allow you to create a LOAD to a local table from a CURSOR that references a SELECT of a table in the remote server.

The last option could sound complicated but it is not. You just have to define remote elements (nickname, wrapper, etc) and that is it. Once, you have configure that, you do not have to worry about file transfer, states, etc. This option is free because both server are DB2 (you can do that with other RDBS)

For more information:

OTHER TIPS

There are multiple options (using scripting or DB2 replication):

  1. Script to export data on one server, eventually tar/gz and send it to the 2nd server per SSH/SCP. On the 2nd Server another script extracts and loads the data.

  2. DB2 hat build in replication support.

Check DB2 infocenter@IBM or Google. This is an easy and very common task.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top