Quote:
|
Originally Posted by shahnazurs
Can someone tell me how to load data from excel sheet to db2 table? Is there any way if I use , (comma) as delimiter to load only particular fields into the table rather than all fields.
|
The answer depends on the version and platform where you run DB2.
For DB2 v8 and v9 on z/OS, use the following to load a CSV file with three columns (of types CHAR, DATE, and INTEGER) into a table with column names col1, col2 and col3 (with possibly more than these three columns):
Code:
LOAD DATA FORMAT delimited INTO TABLE mytablename
(col1 CHAR, col2 DATE EXTERNAL, col3 INT EXTERNAL)
Make sure that the non-numerical CSV fields in the file (in my example: columns 1 and 2) are quoted with double quotes.
If you want to skip some fields, you cannot use CSV but you have to use fixed-position fields instead. In that case, just specify the column names you need (and their starting position on each line in the file) between the parentheses.