Learnt something new in Oracle, its all about handling mutliple load options for loading into multiple table using sql-loader.
Here is a quick demo of what i have.
rajesh@ORA10GR2> select * from t1;
no rows selected
rajesh@ORA10GR2> select * from t2;
X Y
---------- ----------
2 1
1 row selected.
rajesh@ORA10GR2>
D:\app\179818\product\11.2.0\dbhome_1\BIN>sqlldr rajesh/oracle@iradsnvl control=d:\ctl.txt log=d:\log.txt data=d:\data.txt
SQL*Loader: Release 11.2.0.3.0 - Production on Tue Oct 22 13:58:52 2013
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
Commit point reached - logical record count 4
D:\app\179818\product\11.2.0\dbhome_1\BIN>exit
rajesh@ORA10GR2>
rajesh@ORA10GR2>
rajesh@ORA10GR2> select * from t1;
X Y
---------- ----------
1 1
1 2
1 3
3 rows selected.
rajesh@ORA10GR2> select * from t2;
X Y
---------- ----------
2 4
1 row selected.
rajesh@ORA10GR2>
now the data got loaded into T1 but got updated in T2.
Here is what i have in Control file ( Table T1 in TRUNCATE option and T2 in REPLACE option)
D:\>type ctl.txt
LOAD DATA
INTO TABLE T1
TRUNCATE
WHEN X='1'
FIELDS TERMINATED BY ',' TRAILING NULLCOLS
(
X ,
Y
)
INTO TABLE T2
REPLACE
WHEN X='2'
FIELDS TERMINATED BY ',' TRAILING NULLCOLS
(
X position(1) ,
Y
)
and data file contents are here.
D:\>type data.txt
1,1
1,2
1,3
2,4
Here is a quick demo of what i have.
rajesh@ORA10GR2> select * from t1;
no rows selected
rajesh@ORA10GR2> select * from t2;
X Y
---------- ----------
2 1
1 row selected.
rajesh@ORA10GR2>
D:\app\179818\product\11.2.0\dbhome_1\BIN>sqlldr rajesh/oracle@iradsnvl control=d:\ctl.txt log=d:\log.txt data=d:\data.txt
SQL*Loader: Release 11.2.0.3.0 - Production on Tue Oct 22 13:58:52 2013
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
Commit point reached - logical record count 4
D:\app\179818\product\11.2.0\dbhome_1\BIN>exit
rajesh@ORA10GR2>
rajesh@ORA10GR2>
rajesh@ORA10GR2> select * from t1;
X Y
---------- ----------
1 1
1 2
1 3
3 rows selected.
rajesh@ORA10GR2> select * from t2;
X Y
---------- ----------
2 4
1 row selected.
rajesh@ORA10GR2>
now the data got loaded into T1 but got updated in T2.
Here is what i have in Control file ( Table T1 in TRUNCATE option and T2 in REPLACE option)
D:\>type ctl.txt
LOAD DATA
INTO TABLE T1
TRUNCATE
WHEN X='1'
FIELDS TERMINATED BY ',' TRAILING NULLCOLS
(
X ,
Y
)
INTO TABLE T2
REPLACE
WHEN X='2'
FIELDS TERMINATED BY ',' TRAILING NULLCOLS
(
X position(1) ,
Y
)
and data file contents are here.
D:\>type data.txt
1,1
1,2
1,3
2,4
No comments:
Post a Comment