Wednesday, June 24, 2009

Oracle 10g: Flush Data To External Table - Using Insert Statement

I'm using external table as a passage to load data from a flat file ''scname.CSV' to respective table - "GBL_SPECIES_MST".

Script:

/*
*
* Pump data to table:
*

*
*
* @Migration SPECIESDIR
* @author Nur Fiza Suhati
* @version 1.0
*
*/
/*
1. Directory to database
*/
CREATE OR REPLACE DIRECTORY SPECIESDIR AS 'C:\oracle\product\10.1.0\oradata\myep';
DROP TABLE SPECIES_EXT;
create table SPECIES_EXT (
ID varchar2(100),SCIENTIFICNAME VARCHAR2(100))
Organization external
(type oracle_loader
default directory SPECIESDIR
access parameters (records delimited by newline
fields terminated by '')
location ('scname.csv'))
reject limit 100000;

TRUNCATE TABLE GBL_SPECIES_MST;
INSERT INTO GBL_SPECIES_MST (SPECIESID,SCIENTIFICNAME)
(
SELECT SPECIES_EXT.ID,SPECIES_EXT.SCIENTIFICNAME
FROM SPECIES_EXT SPECIES_EXT
)

;

No comments: