EXTERNAL_TABLE parameter instructs SQL*Loader whether to load data using the external tables option.
Syntax and Description
EXTERNAL_TABLE=[NOT_USED | GENERATE_ONLY | EXECUTE]
The possible values are as follows:
NOT_USED - the default value. It means the load is performed using either conventional or direct path mode.
GENERATE_ONLY - places all the SQL statements needed to do the load using external tables, as described in the control file, in the SQL*Loader log file. These SQL statements can be edited and customized. The actual load can be done later without the use of SQL*Loader by executing these statements in SQL*Plus.
EXECUTE - attempts to execute the SQL statements that are needed to do the load using external tables. However, if any of the SQL statements returns an error, then the attempt to load stops. Statements are placed in the log file as they are executed. This means that if a SQL statement returns an error, then the remaining SQL statements required for the load will not be placed in the log file.
If you use
EXECUTE and also use the
SEQUENCE parameter in your SQL*Loader control file, then SQL*Loader creates a database sequence, loads the table using that sequence, and then deletes the sequence. The results of doing the load this way will be different than if the load were done with conventional or direct path. (For more information about creating sequences, see
SEQUENCE in Oracle Database SQL Language Reference.)
EXTERNAL_TABLE parameter is specified, any datetime data types (for example,
TIMESTAMP) in a SQL*Loader control file are automatically converted to a
CHAR data type and use the external tables
date_format_spec clause. See "date_format_spec".
Note that the external table option uses directory objects in the database to indicate where all input data files are stored and to indicate where output files, such as bad files and discard files, are created. You must have
READ access to the directory objects containing the data files, and you must have
WRITE access to the directory objects where the output files are created. If there are no existing directory objects for the location of a data file or output file, then SQL*Loader will generate the SQL statement to create one. Therefore, when the
EXECUTE option is specified, you must have the
DIRECTORY privilege. If you want the directory object to be deleted at the end of the load, then you must also have the
EXECUTE qualifier tells SQL*Loader to create an external table that can be used to load data and then executes the
INSERT statement to load the data. All files in the external table must be identified as being in a directory object. SQL*Loader attempts to use directory objects that already exist and that you have privileges to access. However, if SQL*Loader does not find the matching directory object, then it attempts to create a temporary directory object. If you do not have privileges to create new directory objects, then the operation fails.
To work around this, use
GENERATE_ONLY to create the SQL statements that SQL*Loader would try to execute. Extract those SQL statements and change references to directory objects to be the directory object that you have privileges to access. Then, execute those SQL statements.
When using a multi-table load, SQL*Loader does the following:
Creates a table in the database that describes all fields in the input data file that will be loaded into any table.
INSERT statement to load this table from an external table description of the data.
INSERT statement for every table in the control file.
To see an example of this, run case study 5, but add the
EXTERNAL_TABLE=GENERATE_ONLY parameter. To guarantee unique names in the external table, SQL*Loader uses generated names for all fields. This is because the field names may not be unique across the different tables in the control file.
Julian dates cannot be used when you insert data into a database table from an external table through SQL*Loader. To work around this, use
TO_CHAR to convert the Julian date format, as shown in the following example:
TO_CHAR(TO_DATE(:COL1, 'MM-DD-YYYY'), 'J')
Built-in functions and SQL strings cannot be used for object elements when you insert data into a database table from an external table.