External tables are read-only tables in which the data is stored outside the database in flat files. The data can be queried like a virtual table. Metadata of an external table is created with the CREATE TABLE command. Without loading data into your database, you can query the data directly from flat files. (In Oracle 8i, you need to load that data using SQL*Loader.) Restriction: No DML operations are possible and no indexes can be created.
CREATE table emp_ext ( empno number, first_name char(30), last_naem char(30) ORGANIZATION EXTERNAL ( TYPE oracle_loader DEFAULT DIRECTORY flatfile_dir ACCESS PARAMETERS ( RECORDS DELIMITED BY NEWLINE FIELDS TERMINATED BY '~' BADFILE 'emp_ext.bad' LOGFILE 'emp_ext.log' MISSING FIELDS ARE NULL) LOCATION ('emp1.txt', 'emp2.txt')) PARALLEL 5 REJECT LIMIT UNLIMITED;In the above example, when the external table "emp_ext" is queried, the data is retrieved from the external data files.
For More Information
- Feedback: E-mail the editor with your thoughts about this tip.
- More tips: Hundreds of free Oracle tips and scripts.
- Tip contest: Have an Oracle tip to offer your fellow DBAs and developers? The best tips submitted will receive a cool prize -- submit your tip today!
- Ask the Experts: Our SQL, database design, Oracle, SQL Server, DB2, relational model, and data warehousing gurus are waiting to answer your toughest questions.
- Forums: Ask your technical Oracle questions--or help out your peers by answering them--in our active forums.
- Best Web Links: Oracle tips, tutorials, and scripts from around the Web.