05.11.2015 Views

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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

684<br />

CHAPTER 15 ■ DATA LOADING AND UNLOADING<br />

• READSIZE: This is the default buffer used by <strong>Oracle</strong> to read the input data file. It is 1MB<br />

in this case. This memory comes from the PGA in dedicated server mode <strong>and</strong> the SGA<br />

in shared server mode, <strong>and</strong> it is used to buffer the information in the input data file for<br />

a session (refer to Chapter 4, where we discussed PGA <strong>and</strong> SGA memory). Keep that fact<br />

in mind if you’re using shared servers: the memory is allocated from the SGA.<br />

• SKIP 7: This determines how many records in the input file should be skipped. You<br />

might be asking, “Why ‘skip 7’?” Well, we used INFILE * in this example; SKIP 7 is used<br />

to skip over the control file itself to get to the embedded data. If we did not use INFILE *,<br />

there would be no SKIP clause at all.<br />

• FIELDS TERMINATED BY: This is just as we used in the control file itself. However, the<br />

external table did add LDRTRIM, which st<strong>and</strong>s for LoaDeR TRIM. This is a trim mode<br />

that emulates the way in which SQLLDR trims data by default. Other options include<br />

LRTRIM, LTRIM, <strong>and</strong> RTRIM for left/right trimming of whitespace; <strong>and</strong> NOTRIM to preserve<br />

all leading/trailing whitespace.<br />

• REJECT ROWS WITH ALL NULL FIELDS: This causes the external table to log to the bad file<br />

any entirely blank lines <strong>and</strong> to not load that row.<br />

• The column definitions themselves: This is the metadata about the expected input data<br />

values. They are all character strings in the data file to be loaded, <strong>and</strong> they can be up to<br />

255 characters in length (SQLLDR’s default size), <strong>and</strong> terminated by , <strong>and</strong> optionally<br />

enclosed in quotes.<br />

■Note For a comprehensive list of all options available to you when using external tables, review the<br />

<strong>Oracle</strong> Utilities Guide manual. This reference contains a section dedicated to external tables. The <strong>Oracle</strong> SQL<br />

Reference Guide manual provides the basic syntax, but not the details of the ACCESS PARAMETERS section.<br />

Lastly, we get to the LOCATION section of the external table definition:<br />

location<br />

(<br />

'demo1.ctl'<br />

)<br />

) REJECT LIMIT UNLIMITED<br />

That tells <strong>Oracle</strong> the name of the file to load, which is demo1.ctl in this case since we used<br />

INFILE * in the original control file. The next statement in the control file is the default INSERT<br />

that can be used to load the table from the external table itself:<br />

INSERT statements used to load internal tables:<br />

------------------------------------------------------------------------<br />

INSERT /*+ append */ INTO DEPT<br />

(<br />

DEPTNO,<br />

DNAME,

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

Saved successfully!

Ooh no, something went wrong!