Five Techniques for Loading Flat File Data into Oracle Tables

Transcription

Five Techniques for Loading Flat File Data into Oracle Tables
Mingguang Xu
Office of Institutional Research
The University of Georgia
SQL Loader
}  External Table
}  Oracle Warehouse Builder
}  Toad Data Loading Wizard
}  SQL Developer
} 
Comes with Oracle server and client install
}  Traditional
}  Can be used on either server side or client
side
}  Easy to build into a Unix/Linux script
}  Need to write a control file
} 
A feature starting from Oracle 9i
}  Pros: flat files can be treated as tables
}  Cons: make database less portal
}  Use case: server log file, auditing files
} 
Pros: technically simple:
Step 1. create or replace directory ext_table_dir as ‘/ext_table_data’;
Step 2. create table ext_table (col1 varchar2(5),…..
)
ORGANIZATION EXTERNAL
( TYPE ORACLE_LOADER
DEFAULT DIRECTORY ext_tab_data
ACCESS PARAMETERS (
RECORDS DELIMITED BY NEWLINE
FIELDS TERMINATED BY ','
MISSING FIELD VALUES ARE NULL
( col1 CHAR(5),…… )
LOCATION (‘file1.txt',‘file2.txt') )
PARALLEL 5
REJECT LIMIT UNLIMITED;
Cons: Data less portable, but good for Server side log
files.
} 
} 
Pros: generate DDL for new table matching
the flat file structure; generate control file
Cons: have to learn how to use the tool; only
generate control file
Pros: generate control file; can be scheduled
as a job
}  Cons: the target table must be pre-exist in
DB
} 
Pros: intuitive; can directly use excel file
}  Cons: cannot be programmed
} 
OWB
}  Toad
}  SQL Developer
} 
OWB Demo
OWB Demo
OWB Demo
Step 1. import flat file
OWB Demo
Toad SQL Load Wizard Demo
Toad SQL Load Wizard Demo
SQL Developer Demo: case 1, load data into a new table
SQL Developer Demo: case 1, load data into a new table
SQL Developer Demo - case 1: load data into a new table
SQL Developer Demo - case 1: load data into a new table
SQL Developer Demo - case 1: load data into a new table
SQL Developer Demo - case 1: load data into a new table
SQL Developer Demo - case 1: load data into a new table
SQL Developer Demo - case 1: load data into a new table
SQL Developer Demo - case 2: load data into an existing table
Questions?
Email to: [email protected]