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.

690<br />

CHAPTER 15 ■ DATA LOADING AND UNLOADING<br />

ops$tkyte@ORA10G> select dname<br />

2 from SYS_SQLLDR_X_EXT_DEPT<br />

3 /<br />

DNAME<br />

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

Sales<br />

Accounting<br />

Consulting<br />

Finance<br />

XYZ<br />

ops$tkyte@ORA10G> select deptno<br />

2 from SYS_SQLLDR_X_EXT_DEPT<br />

3 /<br />

DEPTNO<br />

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

10<br />

20<br />

30<br />

40<br />

we get different numbers of rows from each query. The DNAME field was valid for every single record in the<br />

input file, but the DEPTNO column was not. If we do not retrieve the DEPTNO column, it does not fail the<br />

record—the resultset is materially changed.<br />

Using an External Table to Load Different Files<br />

A common need is to use an external table to load data from differently named files over a<br />

period of time. That is, this week we must load file1.dat, <strong>and</strong> next week it will be file2.dat,<br />

<strong>and</strong> so on. So far, we’ve been loading from a fixed file name, demo1.dat. What if we need subsequently<br />

to load from a second file, demo2.dat?<br />

Fortunately, that is pretty easy to accommodate. The ALTER TABLE comm<strong>and</strong> may be used<br />

to repoint the location setting of the external table:<br />

ops$tkyte@ORA10G> alter table SYS_SQLLDR_X_EXT_DEPT<br />

2 location( 'demo2.dat' );<br />

Table altered.<br />

And that would pretty much be it—the very next query of that external table would have it<br />

accessing the file demo2.dat.

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

Saved successfully!

Ooh no, something went wrong!