Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle SQL Loader split data into different tables

I have a Data file that looks like this:

    1            2          3        4             5            6    
FirstName1 | LastName1 | 4224423 | Address1 | PhoneNumber1 | 1/1/1980
FirstName2 | LastName2 | 4008933 | Address1 | PhoneNumber1 | 1/1/1980
FirstName3 | LastName3 | 2344327 | Address1 | PhoneNumber1 | 1/1/1980
FirstName4 | LastName4 | 5998943 | Address1 | PhoneNumber1 | 1/1/1980
FirstName5 | LastName5 | 9854531 | Address1 | PhoneNumber1 | 1/1/1980

My DB has 2 Tables, one for PERSON and one for ADDRESS, so I need to store columns 1,2,3 and 6 in PERSON and column 4 and 5 in ADDRESS. All examples provided in the SQL Loader documentation address this case but only for fixed size columns, and my data file is pipe delimited (and spiting this into 2 different data files is not an option).

Do someone knows how to do this?

As always help will be deeply appreciated.

like image 535
Chepech Avatar asked Oct 14 '22 21:10

Chepech


1 Answers

Another option may be to set up the file as an external table and then run inserts selecting the columns you want from the external table.

like image 145
Craig Avatar answered Nov 15 '22 13:11

Craig