IBM Support

How to extract data from a corrupted table using db2dart

Question & Answer


Question

This technote provides troubleshooting information for the situation where your table data is corrupted and you do not have a recent good backup to restore your data. It describes a method for dumping the table data.

Answer

You can dump table data by using the ddel option of the db2dart command. The database needs to be offline to run the db2dart command.

This example extracts data from the EMPLOYEE table residing in the default USERSPACE1 tablespace with id 2 in the SAMPLE database in a DB2 V9.7 environment.

$db2dart sample /DDEL



Table object data formatting start.
Please enter
Table ID or name, tablespace ID, first page, num of pages:
EMPLOYEE,2,0,5

14 of 14 columns in the table will be dumped.
Column numbers and datatypes of the columns dumped:
0 CHAR() -FIXED LENGTH CHARACTER STRING
1 VARCHAR() -VARIABLE LENGTH CHARACTER STRING
2 CHAR() -FIXED LENGTH CHARACTER STRING
3 VARCHAR() -VARIABLE LENGTH CHARACTER STRING
4 CHAR() -FIXED LENGTH CHARACTER STRING
5 CHAR() -FIXED LENGTH CHARACTER STRING
6 DATE
7 CHAR() -FIXED LENGTH CHARACTER STRING
8 SMALLINT
9 CHAR() -FIXED LENGTH CHARACTER STRING
10 DATE
11 DECIMAL
12 DECIMAL
13 DECIMAL
Default filename for output data file is TS2T6.DEL,
do you wish to change filename used? y/n
n

Filename used for output data file is TS2T6.DEL. If existing file, data will be appended to it.

Formatted data being dumped ...
Dumping Page 0 ....
Table object data formatting end.

The requested DB2DART processing has completed successfully!
Complete DB2DART report found in:
/home/v97fp2/sqllib/db2dump/DART0000/SAMPLE.RPT


Note: Above example dumps 5 pages of data from the table Employee. If you are not sure of the number of pages, use a large number such as 99999 so that all the pages of the table will get dumped.


Sample contents in the output file (called TS2T6.DEL in this example) found in the location /home/v97fp2/sqllib/db2dump/DART0000 are as follows:

$cat TS2T6.DEL

"000010","CHRISTINE","I","HAAS","A00","3978",19950101,"PRES ",18,"F",19630824,+0152750.00,+0001000.00,+0004220.00
.....

"200340","ROY","R","ALONZO","E21","5698",19970705,"FIELDREP",16,"M",19560517,+0031840.00,+0000500.00,+0001907.00

[{"Product":{"code":"SSEPGG","label":"Db2 for Linux, UNIX and Windows"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Component":"DB2 Tools - db2dart","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"}],"Version":"9.7;9.5;9.1","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

Document Information

Modified date:
16 June 2018

UID

swg21509964