Goal:
External Table create from Flat File in Oracle
Statement:
----Login as sys user
CREATE OR REPLACE DIRECTORY ext_tab_data AS 'D:\Attachment';
GRANT READ WRITE ON DIRECTORY ext_tab_data TO SCOTT;
GRANT CREATE TABLE TO SCOTT;
----Login as scott user
CREATE TABLE ext_table (
country_code VARCHAR2(5),
country_name VARCHAR2(50),
country_language VARCHAR2(50)
)
ORGANIZATION EXTERNAL (
TYPE ORACLE_LOADER
DEFAULT DIRECTORY ext_tab_data
ACCESS PARAMETERS (
RECORDS DELIMITED BY NEWLINE
FIELDS TERMINATED BY ','
MISSING FIELD VALUES ARE NULL
(
country_code CHAR(5),
country_name CHAR(50),
country_language CHAR(50)
)
)
LOCATION ('Table1.txt','Table2.txt')
)
PARALLEL 5
REJECT LIMIT UNLIMITED;
---or---
CREATE TABLE ext_table (
country_code VARCHAR2(5),
country_name VARCHAR2(50),
country_language VARCHAR2(50)
)
ORGANIZATION EXTERNAL (
TYPE ORACLE_LOADER
DEFAULT DIRECTORY ext_tab_data
ACCESS PARAMETERS (
RECORDS DELIMITED BY NEWLINE
MISSING FIELD VALUES ARE NULL
(
country_code CHAR(5),
country_name CHAR(50),
country_language CHAR(50)
)
)
LOCATION ('Table1.txt','Table2.txt')
)
PARALLEL 5
REJECT LIMIT UNLIMITED;
SELECT * FROM ext_table;
----Login as sys user
DROP TABLE EXT_TABLE PURGE;
External Table create from Flat File in Oracle
Statement:
----Login as sys user
CREATE OR REPLACE DIRECTORY ext_tab_data AS 'D:\Attachment';
GRANT READ WRITE ON DIRECTORY ext_tab_data TO SCOTT;
GRANT CREATE TABLE TO SCOTT;
----Login as scott user
CREATE TABLE ext_table (
country_code VARCHAR2(5),
country_name VARCHAR2(50),
country_language VARCHAR2(50)
)
ORGANIZATION EXTERNAL (
TYPE ORACLE_LOADER
DEFAULT DIRECTORY ext_tab_data
ACCESS PARAMETERS (
RECORDS DELIMITED BY NEWLINE
FIELDS TERMINATED BY ','
MISSING FIELD VALUES ARE NULL
(
country_code CHAR(5),
country_name CHAR(50),
country_language CHAR(50)
)
)
LOCATION ('Table1.txt','Table2.txt')
)
PARALLEL 5
REJECT LIMIT UNLIMITED;
---or---
CREATE TABLE ext_table (
country_code VARCHAR2(5),
country_name VARCHAR2(50),
country_language VARCHAR2(50)
)
ORGANIZATION EXTERNAL (
TYPE ORACLE_LOADER
DEFAULT DIRECTORY ext_tab_data
ACCESS PARAMETERS (
RECORDS DELIMITED BY NEWLINE
BADFILE 'ext_tab_data':'ext_table.bad' DISCARDFILE 'ext_tab_data':'ext_table.dis' LOGFILE 'ext_tab_data':'ext_table.log'FIELDS TERMINATED BY ','
MISSING FIELD VALUES ARE NULL
(
country_code CHAR(5),
country_name CHAR(50),
country_language CHAR(50)
)
)
LOCATION ('Table1.txt','Table2.txt')
)
PARALLEL 5
REJECT LIMIT UNLIMITED;
SELECT * FROM ext_table;
----Login as sys user
DROP TABLE EXT_TABLE PURGE;