Home » RDBMS Server » Server Utilities » SQLLDR Case5 Load into multiple tables
SQLLDR Case5 Load into multiple tables [message #178300] |
Tue, 20 June 2006 09:25 |
swamy99
Messages: 30 Registered: June 2006
|
Member |
|
|
Is there any way we can load the CSV file into multiple tables selecting only few fields from the csv into multiple tables?
Exampless from Utilities, SQLLDR, Case5 shows how to do with fixed width where you can specify the position when loading the data into multiple tables, but I am trying to load the specified fields from the CSV file into multiple tables. Is there anyway we can specify only required fields that can be loaded into multiple tables?
|
|
|
|
|
|
Re: SQLLDR Case5 Load into multiple tables [message #178314 is a reply to message #178308] |
Tue, 20 June 2006 10:38 |
swamy99
Messages: 30 Registered: June 2006
|
Member |
|
|
Here is the scenario.
col1 col2 col3 col4 col5 col6 col7
123, 456, 789, 100, 111, 222, 333
123, 456, 444, 555, 666, 777, 888
123, 456, 555, 555, 567, 678, 789
123, 234, 345, 456, 567, 678, 789
987, 876, 765, 654, 543, 432, 321
987, 876, 123, 234, 345, 456, 567
.................................
.................................
The data is mapped into table 1 with
col1 -> FLD1
col2 -> FLD2
col4 -> FLD3
col6 -> FLD4
col7 -> FLD5
The data should go to table 1 is
FLD1 FLD2 FLD3 FLD4 FLD5
123 456 100 222 333
123 456 555 777 888
123 456 555 678 789
123 234 456 678 789
987 876 654 432 321
987 876 234 456 567
The data is mapped into table 2 with (As Primary keys)
col1 -> FLD6
col2 -> FLD7
The data should go into table2 is
FLD6 FLD7
123 456
123 234
987 876
Just like how it is done with "Case Study 5: Loading Data into Multiple Tables" but need it with CSV file.
Hope this helps.
[Updated on: Tue, 20 June 2006 11:32] Report message to a moderator
|
|
|
Re: SQLLDR Case5 Load into multiple tables [message #178339 is a reply to message #178314] |
Tue, 20 June 2006 12:40 |
|
Mahesh Rajendran
Messages: 10708 Registered: March 2002 Location: oracleDocoVille
|
Senior Member Account Moderator |
|
|
For the given sample, you can just use this.
Else we may need to doctor the file.
oracle@mutation#cat file.ctl
LOAD DATA
infile 'file.dat'
replace INTO TABLE one
FIELDS TERMINATED BY "," optionally enclosed by '"' trailing nullcols
(
c1,
c2,
dummycol3 filler,
c3,
dummycol5 filler,
c4,
c5
)
into table two
replace
FIELDS TERMINATED BY "," optionally enclosed by '"' trailing nullcols
(
c1 POSITION(1),
c2 POSITION(5)
)
oracle@mutation#cat file.dat
123,456,789,100,111,222,333
123,456,444,555,666,777,888
123,456,555,555,567,678,789
123,234,345,456,567,678,789
987,876,765,654,543,432,321
987,876,123,234,345,456,567
oracle@mutation#sqlldr userid=scott/tiger control=file.ctl
SQL*Loader: Release 9.2.0.4.0 - Production on Tue Jun 20 13:38:38 2006
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Commit point reached - logical record count 6
oracle@mutation#query mutation scott.one
C1 C2 C3 C4 C5
---------- ---------- ---------- ---------- ----------
123 456 100 222 333
123 456 555 777 888
123 456 555 678 789
123 234 456 678 789
987 876 654 432 321
987 876 234 456 567
6 rows selected.
oracle@mutation#query mutation scott.two
C1 C2
---------- ----------
123 456
123 456
123 456
123 234
987 876
987 876
6 rows selected.
|
|
|
Re: SQLLDR Case5 Load into multiple tables [message #178345 is a reply to message #178339] |
Tue, 20 June 2006 13:03 |
swamy99
Messages: 30 Registered: June 2006
|
Member |
|
|
Thanks for the solution, but still there is something that I am still concerned about. When loading into table two, we see lot of duplicates in there. I want the loader process to eliminate those duplicates during the load itself.
If we look closely in CASE 5, 'emp' table has only the distinct number of records where as 'proj' has multiple records for the same empno. I am looking for that kind of solution but since there are no conditions, can we still get it without the duplicates. Thanks
|
|
|
|
|
Re: SQLLDR Case5 Load into multiple tables [message #179508 is a reply to message #178587] |
Tue, 27 June 2006 14:53 |
swamy99
Messages: 30 Registered: June 2006
|
Member |
|
|
Is there any way to split the field in the above example into two separate records if there is a ';' condition.
ex:
123,456,789,100,111,222,333;456
123,456,444,555,666,777,888;567
123,456,555,555,567,678,789
123,234,345,456,567,678,789
987,876,765,654,543,432,321;111
987,876,123,234,345,456,567
The first, second and fifth rows has ';', so it needs to split into two separate records. For the first record, split 333 for one record with 456 as second record keeping the above suggested solution.
What exactly I am looking for is, if there is any condition that we can apply based on the length of the field using 'WHEN' condition. Thanks.
[Updated on: Tue, 27 June 2006 15:43] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Mon Jan 13 14:25:55 CST 2025
|