I'm having problems with oracle external table I have a text file will 50+ unnecessary columns, Now I want to select a few columns from the text file to my external table.
create table tmpdc_ticket(
SERVICE_ID CHAR(144),
SERVICE_TYPE CHAR(50),
CUSTOMER_NAME CHAR(200),
TELEPHONE_NO CHAR(144),
ACCOUNT_NUMBER CHAR(144),
FAULT_STATUS CHAR(50),
BUSINESS_GROUP CHAR(100)
)
organization external(
type oracle_loader
default directory sample_directory
access parameters(
records delimited by newline
nologfile
skip 1
fields terminated by '|'
missing field values are null
(SERVICE_ID CHAR(144),
SERVICE_TYPE CHAR(50),
CUSTOMER_NAME CHAR(200),
TELEPHONE_NO CHAR(144),
ACCOUNT_NUMBER CHAR(144),
FAULT_STATUS CHAR(50),
BUSINESS_GROUP CHAR(100)
)
)
location(sample_directory:'sample_file.txt')
)
reject limit 1
noparallel
nomonitoring;
However it seems like the oracle_loader is doing inserting from the first column from my textfile. Is it possible to get already like for example the 3rd columns from the textfile?
If you have delimited fields in your file that you want to ignore, just specify them in the field list clause with a dummy field name, and don't include them in the table column list. This will ignore the first two fields in the file:
So if you have a file containing (very contrived values in this case):
Then the table will not see the first two fields, and will contain:
You can put more dummy fields in the middle of the field list, not just at the start, if you need to. And you can call them anything of course, as long as the names don't clash with fields you are using, so you might want to give them meaningful names to ease maintenance and make life easier if you decide you do want to include another one in the table columns later.
Incidentally, you probably want your table columns to be declared as VARCHAR2 rather than CHAR: