1

I am using SEQUENCE keyword in SQL Loader control file to generate primary keys. But for a special scenario I would like to use Oracle sequence in the control file. The Oracle documentation for SQL Loader doesn't mentioned anything about it. does SQL Loader support it?

3 Answers 3

4

I have managed to load without using the dummy by the switching the sequence to be the last column as in :

LOAD DATA
INFILE 'data.csv'
APPEND INTO TABLE my_data
FIELDS TERMINATED BY ','
(
    name char,
    ID "MY_SEQUENCE.NEXTVAL"
)

and data.csv would be like:

"dave"
"carol"
"tim"
"sue"
Sign up to request clarification or add additional context in comments.

1 Comment

You have to add TRAILING NULLCOLS to the control file.
2

I have successfully used a sequence from my Oracle 10g database to populate a primary key field during an sqlldr run:

Here is my data.ctl:

LOAD DATA
INFILE 'data.csv'
APPEND INTO TABLE my_data
FIELDS TERMINATED BY ','
(
  ID "MY_SEQUENCE.NEXTVAL",
  name char
)

and my data.csv:

-1, "dave"
-1, "carol"
-1, "tim"
-1, "sue"

For some reason you have to put a dummy value in the CSV file even though you'd figure that sqlldr would just figure out that you wanted to use a sequence.

Comments

1

I don't think so, but you can assign the sequence via the on insert trigger unless this is a direct path load.

1 Comment

Thank you @REW. I am not using direct path load.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.