05.11.2015 Views

Apress.Expert.Oracle.Database.Architecture.9i.and.10g.Programming.Techniques.and.Solutions.Sep.2005

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

632<br />

CHAPTER 14 ■ PARALLEL EXECUTION<br />

Setting Up<br />

To get started, we need an external table. I’ve found time <strong>and</strong> time again that I have a legacy<br />

control file from SQL*Loader that I used to use to load data. One that looks like this, for example:<br />

LOAD DATA<br />

INFILE '/tmp/big_table.dat'<br />

INTO TABLE big_table<br />

REPLACE<br />

FIELDS TERMINATED BY '|'<br />

(<br />

id ,owner ,object_name ,subobject_name ,object_id<br />

,data_object_id ,object_type ,created ,last_ddl_time<br />

,timestamp ,status ,temporary ,generated ,secondary<br />

)<br />

We can convert this easily into an external table definition using SQL*Loader itself:<br />

$ sqlldr big_table/big_table big_table.ctl external_table=generate_only<br />

SQL*Loader: Release 10.1.0.3.0 - Production on Mon Jul 11 14:16:20 2005<br />

Copyright (c) 1982, 2004, <strong>Oracle</strong>. All rights reserved.<br />

Notice the parameter EXTERNAL_TABLE passed to SQL*Loader. It causes SQL*Loader in this<br />

case to not load data, but rather to generate a CREATE TABLE statement for us in the log file.<br />

This CREATE TABLE statement looked as follows (this is an abridged form; I’ve edited out repetitive<br />

elements to make the example smaller):<br />

CREATE TABLE "SYS_SQLLDR_X_EXT_BIG_TABLE"<br />

(<br />

"ID" NUMBER,<br />

...<br />

"SECONDARY" VARCHAR2(1)<br />

)<br />

ORGANIZATION external<br />

(<br />

TYPE oracle_loader<br />

DEFAULT DIRECTORY SYS_SQLLDR_XT_TMPDIR_00000<br />

ACCESS PARAMETERS<br />

(<br />

RECORDS DELIMITED BY NEWLINE CHARACTERSET WE8ISO8859P1<br />

BADFILE 'SYS_SQLLDR_XT_TMPDIR_00000':'big_table.bad'<br />

LOGFILE 'big_table.log_xt'<br />

READSIZE 1048576<br />

FIELDS TERMINATED BY "|" LDRTRIM<br />

REJECT ROWS WITH ALL NULL FIELDS<br />

(<br />

"ID" CHAR(255)<br />

TERMINATED BY "|",<br />

....<br />

"SECONDARY" CHAR(255)

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!