You’ll need to be in the DB2 Command Line for this. Also, the version of your DB2 client should match the version of the DB or be higher than the DB version (i.e. no using a version 7 client to go after a version 8 DB).

To get data out of a db2 table:

db2 "export to [file_name] of [file_type] select * from [table]"

[file_name] is a fully qualified name of the ouput file
[file_type] is either del (delimited) or ixf (db2 native format).
[table] is a fully qualified table, nickname, or view

For example:

db2 "export to /home/user/people.ixf of ixf select * from db2dba.people"

Performance is critical. Load outperforms Import in all scenarios, sometimes by as much as a factor of 10 (May be closer to 6 times for UNIX systems).

You want to LOAD FROM CURSOR to avoid the creation of an intermediate file.

Use IMPORT when:

You have smaller tables.

You want additional “safety” in the case of an error.

Target table needs to be created from the input file (applicable to PC/IXF files only.)

Logging of every inserted record is necessary.

You require triggers to fire.

You need to be able to update the table while appending data to the table.

In general I would recommend IMPORT unless performance is absolutely critical or you have more than 10 million records (yes, that’s relatively arbitrary – the point is a LOT of data). The primary reason for this is that a botched load can send your entire table space into backup pending and leave you dead in the water. If you do decided to do a load, make sure you include steps to recover from the failed load (but that’s a topic for another day).

If you’ve ever received a java.lang.OutOfMemoryError when processing a large amount of data, there’s a chance you need to manually specify the JVM size if you can. Here’s an example…

java -Xms64m -Xmx256m MyProgram

… Of course, another option you may want to consider is to structure your program more efficiently (i.e. don’t store all that data in memory, process in blocks, use a tool more suitable to the task like BCP or DB2 LOAD).