Pages

Monday, July 20, 2015

SQL Loader (Different Types of Files/Contents)


SQL*Loader is a bulk loader utility used for moving data from external files into the Oracle database. Its syntax is similar to that of the DB2 Load utility, but comes with more options. SQL*Loader supports various load formats, selective loading, and multi-table loads.
When we speak of the SQL*Loader environment, we are referring to the database, the SQL*Loader executable, and all the different files that you need to be concerned with when using SQL*Loader. These are shown in Figure







The SQL*Loader environment
 

The SQL*Loader Control File

The SQL*Loader control file is the key to any load process. The control file provides the following information to SQL*Loader:
    • The name and location of the input data file
    • The format of the records in the input data file
    • The name of the table or tables to be loaded
    • The correspondence between the fields in the input record and the columns in the database tables being loaded
    • Selection criteria defining which records from the input file contain data to be inserted into the destination database tables.
    • The names and locations of the bad file and the discard file

The Log File

The log file is a record of SQL*Loader's activities during a load session. It contains information such as the following:
    • The names of the control file, log file, bad file, discard file, and data file
    • The values of several command-line parameters
    • A detailed breakdown of the fields and data types in the data file that was loaded
    • Error messages for records that cause errors
    • Messages indicating when records have been discarded
    • A summary of the load that includes the number of logical records read from the data file, the number of rows rejected because of errors, the number of rows discarded because of selection criteria, and the elapsed time of the load

Always review the log file after a load to be sure that no errors occurred, or at least that no unexpected errors occurred. This type of information is written to the log file, but is not displayed on the terminal screen.

The Bad File and the Discard File

Whenever you insert data into a database, you run the risk of that insert failing because of some type of error. Integrity constraint violations undoubtedly represent the most common type of error. However, other problems, such as the lack of free space in a tablespace, can also cause insert operations to fail. Whenever SQL*Loader encounters a database error while trying to load a record, it writes that record to a file known as the bad file.
Discard files, on the other hand, are used to hold records that do not meet selection criteria specified in the SQL*Loader control file. By default, SQL*Loader will attempt to load all the records contained in the input file.

No comments:

Post a Comment