sqlloader loads data from external files into tables of an oracle database.we use sqlloader to load data from multiple datafiles during the same load session,loads data into multiple tables during the same load session,load data from disk,tape or named pipe.It will be in the location of
[subbu@subbuapps bin]$ ls sqlldr
sqlldr
[subbu@subbuapps bin]$ pwd
/u01/app/subbu/product/11.2.0.4/bin
USING SQL loader:-
steps:- 1)create a flat file(eg .dat file)
[subbu@subbuapps ~]$ vi product.dat
100,kkk,9000
101,ppp,8970
102,ttt,1900
:wq
2)SQL> grant connect,resource to u1 identified by u1;
Grant succeeded.
SQL> conn u1/u1
Connected.
SQL> sho user;
USER is "U1"
3)SQL> create table emp(id number(10),name varchar2(10),sal number(10));
Table created.
4)create a controlfile product.ctl
vi product.ctl
load data
infile '/u01/app/product.dat'
into table emp
fields terminated by ","
(id,name,sal)
:wq
Here we loading the data from product.dat file to database table.
5)[subbu@subbuapps ~]$ sqlldr userid=u1/u1 control=product.ctl log=product.log
SQL*Loader: Release 11.2.0.4.0 - Production on Wed Nov 2 17:40:05 2016
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
Commit point reached - logical record count 3
6)SQL> conn u1/u1
Connected.
SQL> sho user;
USER is "U1"
SQL> select * from emp;
ID NAME SAL
---------- ---------- ----------
100 kkk 9000
101 ppp 8970
102 ttt 1900
7)SQL> commit;
Commit complete.
8)SQL> alter database add supplemental log data;
Database altered.
9)[subbu@subbuapps ~]$ mkdir demo
10)SQL> show parameter utl_file_dir
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
utl_file_dir string
11)SQL> alter system set utl_file_dir='/u01/app/demo' scope=spfile;
System altered.
12)SQL> conn u1/u1
Connected.
SQL> select * from emp;
ID NAME SAL
---------- ---------- ----------
100 kkk 9000
101 ppp 8970
102 ttt 1900
SQL> delete from emp;
3 rows deleted.
SQL> commit;
Commit complete
13)SQL> show user;
USER is "U1"
SQL> conn / as sysdba
Connected.
SQL> exec dbms_logmnr_d.build('dfile','/u01/app/demo');
PL/SQL procedure successfully completed.
14)SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
/u01/app/subbu/redlog1a.log
/u01/app/subbu/redolog1b.log
/u01/app/subbu/redlog2a.log
/u01/app/subbu/redolog2b.log
SQL> exec dbms_logmnr.add_logfile('/u01/app/subbu/redlog1a.log');
PL/SQL procedure successfully completed.
15)SQL> exec dbms_logmnr.add_logfile('/u01/app/subbu/redlog2a.log');
/SQL procedure successfully completed.
.
[subbu@subbuapps bin]$ ls sqlldr
sqlldr
[subbu@subbuapps bin]$ pwd
/u01/app/subbu/product/11.2.0.4/bin
USING SQL loader:-
steps:- 1)create a flat file(eg .dat file)
[subbu@subbuapps ~]$ vi product.dat
100,kkk,9000
101,ppp,8970
102,ttt,1900
:wq
2)SQL> grant connect,resource to u1 identified by u1;
Grant succeeded.
SQL> conn u1/u1
Connected.
SQL> sho user;
USER is "U1"
3)SQL> create table emp(id number(10),name varchar2(10),sal number(10));
Table created.
4)create a controlfile product.ctl
vi product.ctl
load data
infile '/u01/app/product.dat'
into table emp
fields terminated by ","
(id,name,sal)
:wq
Here we loading the data from product.dat file to database table.
5)[subbu@subbuapps ~]$ sqlldr userid=u1/u1 control=product.ctl log=product.log
SQL*Loader: Release 11.2.0.4.0 - Production on Wed Nov 2 17:40:05 2016
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
Commit point reached - logical record count 3
6)SQL> conn u1/u1
Connected.
SQL> sho user;
USER is "U1"
SQL> select * from emp;
ID NAME SAL
---------- ---------- ----------
100 kkk 9000
101 ppp 8970
102 ttt 1900
7)SQL> commit;
Commit complete.
8)SQL> alter database add supplemental log data;
Database altered.
9)[subbu@subbuapps ~]$ mkdir demo
10)SQL> show parameter utl_file_dir
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
utl_file_dir string
11)SQL> alter system set utl_file_dir='/u01/app/demo' scope=spfile;
System altered.
12)SQL> conn u1/u1
Connected.
SQL> select * from emp;
ID NAME SAL
---------- ---------- ----------
100 kkk 9000
101 ppp 8970
102 ttt 1900
SQL> delete from emp;
3 rows deleted.
SQL> commit;
Commit complete
13)SQL> show user;
USER is "U1"
SQL> conn / as sysdba
Connected.
SQL> exec dbms_logmnr_d.build('dfile','/u01/app/demo');
PL/SQL procedure successfully completed.
14)SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
/u01/app/subbu/redlog1a.log
/u01/app/subbu/redolog1b.log
/u01/app/subbu/redlog2a.log
/u01/app/subbu/redolog2b.log
SQL> exec dbms_logmnr.add_logfile('/u01/app/subbu/redlog1a.log');
PL/SQL procedure successfully completed.
15)SQL> exec dbms_logmnr.add_logfile('/u01/app/subbu/redlog2a.log');
/SQL procedure successfully completed.
It 's excellent posting and useful for developers
ReplyDeleteSql server DBA Online Course Hyderabad