Presentation is loading. Please wait.

Presentation is loading. Please wait.

Using SQL*Loader The SQL*Loader command needs to be run from a DOS window or NT. The SQL*Loader uses the following three files: control file: contains.

Similar presentations


Presentation on theme: "Using SQL*Loader The SQL*Loader command needs to be run from a DOS window or NT. The SQL*Loader uses the following three files: control file: contains."— Presentation transcript:

1 Using SQL*Loader The SQL*Loader command needs to be run from a DOS window or NT. The SQL*Loader uses the following three files: control file: contains directions to read in data file: contains actual data log file: contains the execution log data.

2 SQL*Loader Command line in EMP.BAT file
sqlldr userid=USER_LOGIN_ID/USER_PASSWORD control=d:\Drexel\emp.ctl data=d:\Drexel\emp. log=d:\Drexel\emp.log The above command runs SQL*Loader in Oracle. In USER_LOGIN/USER_PASSWORD, you must supply your own Oracle User ID and Password, separated by a "/". control=d:\Drexel\emp.ctl specifies the location of the control file. data=d:\Drexel\emp. specifies the location of the data file. log=d:\Drexel\emp.log specifies the location of the log file.

3 SQL*Loader Command line in EMP.BAT file
While you may type the line above at the command line, I suggest you enter it into a .BAT file and execute it that way. Too much chance for typing mistakes. You do not need to specify a log file name or directory, but you must do so if you want it named something other than the name of the .CTL file and you want it someplace other than the current directory. It will look for the .DAT extension on the data file. If you do not have an extension, you must end the filename, as I did above, with a "."

4 DATA file The above two lines feed the two records for EMP table
Tony|Hu|| |07-FEB-50|123 st.|M|99000||1|01-jan-18|| Yuan|An|| |07-FEB-40|456 st.|M|29000||1|01-jan-18|| The above two lines feed the two records for EMP table You must enter data for all NOT NULL fields, including those which have a default value. You don't have to quote dates or strings. Each data field is separated by the line (|) as specified in the control file. Each record is ended by the double lines.

5 CONTROL file: EMP.ctl LOAD REPLACE INTO TABLE employee
FIELDS TERMINATED BY '|' (fname,lname,minit,ssn,bdate,address,sex,salary,superssn,dno,start_date,end_date)

6 CONTROL file: EMP.ctl There are many options in the control file not demonstrated here. Oracle will use defaults for any options not explicitly stated. You have the option of REPLACEing (empties table then adds rows), APPENDing (simply adds rows to the table) or INSERTing (adds rows only to an empty table). You will note that I have all the fields in the table named explicitly. This is not necessary. Only those fields where data might be added need be named. But you must include all NOT NULL fields.

7 CONTROL file: EMP.ctl You may include the data to be added in the .CTL file itself. If you do so, your control file would look like this:

8 CONTROL file: EMP.ctl LOAD REPLACE INTO TABLE employee
FIELDS TERMINATED BY '|' (fname,lname,minit,ssn,bdate,address,sex,salary,superssn,dno,start_date,end_date) BEGINDATA Tony|Hu| |07-FEB-50|123 st.|M|99000||1|01-jan-18|| Yuan|An|| |07-FEB-40|456 st.|M|29000||1|01-jan-18||

9 EMP.LOG file SQL*Loader: - Production on Mon Jun 22 16:4:25 1998
(c) Copyright 2018 Oracle Corporation. All rights reserved. Control File: d:\Drexel\emp.ctl Data File: d:\Drexel\emp. Bad File: d:\Drexel\emp.bad Discard File: none specified (Allow all discards) Number to load: ALL Number to skip: 0 Errors allowed: 50 Bind array: rows, maximum of bytes

10 EMP.LOG file cont’d Continuation: none specified
Path used: Conventional Table EMPLOYEE, loaded from every logical record. Insert option in effect for this table: REPLACE

11 EMP.LOG file cont’d Continuation: none specified
Path used: Conventional Table EMPLOYEE, loaded from every logical record. Insert option in effect for this table: REPLACE Column Name Position Len Term Encl Datatype FNAME FIRST * | CHARACTER LNAME NEXT * | CHARACTER MINIT NEXT * | CHARACTER SSN NEXT * | CHARACTER BDATE NEXT * | CHARACTER ADDRESS NEXT * | CHARACTER SEX NEXT * | CHARACTER SALARY NEXT * | CHARACTER SUPERSSN NEXT * | CHARACTER DNO NEXT * | CHARACTER START_DATE NEXT * | CHARACTER END_DATE NEXT * | CHARACTER Table EMPLOYEE: 2 Rows successfully loaded. 0 Rows not loaded due to data errors. 0 Rows not loaded because all WHEN clauses were failed. 0 Rows not loaded because all fields were null. Space allocated for bind array: bytes(46 rows) Space allocated for memory besides bind array: bytes Total logical records skipped: Total logical records read: Total logical records rejected: Total logical records discarded: Run began on Mon Jun 22 16:04: Run ended on Mon Jun 22 16:04: Elapsed time was: :00:01.15 CPU time was: :00:00.11

12 EMP.LOG file cont’d Column Name Position Len Term Encl Datatype
FNAME FIRST * | CHARACTER LNAME NEXT * | CHARACTER MINIT NEXT * | CHARACTER SSN NEXT * | CHARACTER BDATE NEXT * | CHARACTER ADDRESS NEXT * | CHARACTER SEX NEXT * | CHARACTER SALARY NEXT * | CHARACTER SUPERSSN NEXT * | CHARACTER DNO NEXT * | CHARACTER START_DATE NEXT * | CHARACTER END_DATE NEXT * | CHARACTER

13 EMP.LOG file cont’d Table EMPLOYEE: 2 Rows successfully loaded.
0 Rows not loaded due to data errors. 0 Rows not loaded because all WHEN clauses were failed. 0 Rows not loaded because all fields were null. Space allocated for bind array: bytes(46 rows) Space allocated for memory besides bind array: bytes

14 EMP.LOG file cont’d Total logical records skipped: 0
Total logical records read: Total logical records rejected: Total logical records discarded: Run began on Mon Jun 22 16:04: Run ended on Mon Jun 22 16:04: Elapsed time was: :00:01.15 CPU time was: :00:00.11


Download ppt "Using SQL*Loader The SQL*Loader command needs to be run from a DOS window or NT. The SQL*Loader uses the following three files: control file: contains."

Similar presentations


Ads by Google