Go to TogaWare.com Home Page.
GNU/Linux Desktop Survival Guide
by Graham Williams
Google

Importing data from Comma Seperated Value (CSV) files


1. Create a table:

SQL$>$ desc test;
 Name                      Null?    Type
 ------------------------- -------- --------------
 PIN                                NUMBER
 BALANCE                            NUMBER

2. Create controlfile.txt:



load data
infile 'data.csv'
into table test
fields terminated by "," optionally enclosed by '"'
(
    PIN, BALANCE
)

3. From the oracle server, run:



sqlldr username/password@ control=controlfile.txt

4. Check the result:



SQL> select * from test;

    PIN     BALANCE    
------- -----------
      1        1000
      2       23456
      3          -1


Copyright © 1995-2006 [email protected]
Contribue and access the PDF Version