Nice SQLLDR option for external tables

Doug's Oracle Blog

  • Home
  • Papers
  • Books
  • C.V.
  • Fun
  • Blog

Sep 1: Nice SQLLDR option for external tables

(Trying this one again to see if it appears on Orablogs)


SQLLDR has the following command line option EXTERNAL_TABLE = GENERATE_ONLY which, when you give it an old-fashioned SQLLDR control file, will spit out the External Table equivalent in the log file.


e.g.Control File
LOAD DATA
INFILE 'test.txt'
TRUNCATE
INTO TABLE doug_test
FIELDS TERMINATED BY ""
(pk,
test_value CHAR "TO_NUMBER(:test_value, '999,990.90','NLS_NUMERIC_CHARACTERS = '',.''')")
Command to runsqlldr
scott/tiger control=test.ctl external_table=generate_only
Contents of log file (some extraneous text stripped out)
CREATE DIRECTORY statements needed for files
------------------------------------------------------------------------
CREATE DIRECTORY SYS_SQLLDR_XT_TMPDIR_00000 AS 'C:\'


CREATE TABLE statement for external table:
------------------------------------------------------------------------
CREATE TABLE "SYS_SQLLDR_X_EXT_DOUG_TEST
"("PK" NUMBER,"TEST_VALUE" VARCHAR(255))
ORGANIZATION external
(TYPE oracle_loader
DEFAULT DIRECTORY SYS_SQLLDR_XT_TMPDIR_00000
ACCESS PARAMETERS
(RECORDS DELIMITED BY NEWLINE CHARACTERSET WE8MSWIN1252
BADFILE 'SYS_SQLLDR_XT_TMPDIR_00000':'test.bad'
LOGFILE 'test.log_xt'
READSIZE 1048576
FIELDS TERMINATED BY "" LDRTRIM
REJECT ROWS WITH ALL NULL FIELDS
("PK" CHAR(255)TERMINATED BY "","
TEST_VALUE" CHAR(255)TERMINATED BY ""))
location('test.txt'))
REJECT LIMIT UNLIMITED


INSERT statements used to load internal tables:
------------------------------------------------------------------------
INSERT /*+ append */
INTO DOUG_TEST(PK,TEST_VALUE)
SELECT"PK",TO_NUMBER("TEST_VALUE", '999,990.90','
NLS_NUMERIC_CHARACTERS = '',.''')
FROM "SYS_SQLLDR_X_EXT_DOUG_TEST"


statements to cleanup objects created by previous statements:
------------------------------------------------------------------------
DROP TABLE "SYS_SQLLDR_X_EXT_DOUG_TEST"
DROP DIRECTORY SYS_SQLLDR_XT_TMPDIR_00000
This parameter can also be set to EXECUTE, and Oracle will attempt to run the commands shown above, rather than just generating them in the logfile, but my interest was in saving some typing but being able to review and modify the code.This is all in the documentation, as usual, but I'd never noticed it and think it's a useful little feature!


Cheers,


Doug
Posted by Doug Burns Comments: (2) Trackbacks: (0)

Trackbacks
Trackback specific URI for this entry

No Trackbacks

Comments
Display comments as (Linear | Threaded)

#1 - adewri said:
2005-09-02 12:38 - (Reply)

Hi,

This feature is actually quite useful when you want to move from your old sql*loader scripts to external tables.

Cheers...
Amar

#2 - Gus 2008-07-15 23:06 - (Reply)

Thanks a lot!


Add Comment

Standard emoticons like :-) and ;-) are converted to images.
E-Mail addresses will not be displayed and will only be used for E-Mail notifications
BBCode format allowed
 
 

Upcoming Appearances

Hotsos Symposium 2010 - 7th-11th March

Comments

Doug Burns about Advert: Symposium Countdown
Tue, 09.02.2010 09:03
Well I'll be running stuff in VMs, that's for sure, and people have gone on and [...]
Pete Scott about Advert: Symposium Countdown
Tue, 09.02.2010 08:55
It is such a relief to get the paper in (so well done, Doug).... I dispatched [...]
Doug Burns about Parallel Query and 11g
Sun, 07.02.2010 10:09
That could be a long reply, so [...]
Links in Comments

It's a minor source of frustration to me that you can't just paste a Hypertext link into the comments form here but, should you ever want to include a link, all you need to do is use the BBCode format, as mentioned below the comment form.

Here is a link to the relevant part of the document that explains how.

Bookmark

Open All | Close All

Syndicate This Blog

  • XML RSS 2.0 feed
  • ATOM/XML ATOM 1.0 feed
  • XML RSS 2.0 Comments
  • Feedburner Feed

Powered by

Serendipity PHP Weblog

Show tagged entries

xml 11g
xml ACE
xml adaptive thresholds
xml ash
xml Audit Vault
xml AWR
xml Blogging
xml Cuddly Toys
xml Database Refresh
xml Direct Path Reads
xml Fun
xml listener
xml locking
xml oow
xml oow2009
xml OTN
xml Parallel
xml Patching
xml Swingbench
xml The Reality Gap
xml Time Matters
xml Unix/Shell
xml Useful Links

Disclaimer

For the avoidance of any doubt, all views expressed here are my own and not those of past or current employers, clients, friends, Oracle Corporation, my Mum or, indeed, Flatcat. If you want to sue someone, I suggest you pick on Tigger, but I hope you have a good lawyer. Frankly, I doubt any of the former agree with my views or would want to be associated with them in any way.

Design by Andreas Viklund | Conversion to s9y by Carl