0% found this document useful (0 votes)
32 views

External Tables: External Data Is Exposed Like Data Residing in A Regular Oracle Table

This document discusses external tables in Oracle. External tables allow data residing outside of Oracle to be queried like regular database tables. They define metadata for external data sources using DDL and allow SQL and PL/SQL to access this data without needing to first load it into staging tables. External tables support parallelism to improve performance and simplify usage compared to SQL*Loader by controlling security and access within the database rather than at the operating system level. They are configured by creating table definitions that reference external files and parameters like bad files and logs.

Uploaded by

Lenny Mwangi
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views

External Tables: External Data Is Exposed Like Data Residing in A Regular Oracle Table

This document discusses external tables in Oracle. External tables allow data residing outside of Oracle to be queried like regular database tables. They define metadata for external data sources using DDL and allow SQL and PL/SQL to access this data without needing to first load it into staging tables. External tables support parallelism to improve performance and simplify usage compared to SQL*Loader by controlling security and access within the database rather than at the operating system level. They are configured by creating table definitions that reference external files and parameters like bad files and logs.

Uploaded by

Lenny Mwangi
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 4

External Tables

External Data is exposed like Data residing in


a regular Oracle table
– meta data definition via DDL command
– directly accessible inside the database, e.g. with
SQL, PL/SQL, Java
– no temporary staging necessary
– intra-file parallelism eliminates need for manual
split of input file
Transparent Usage of External Tables within
SQL*Loader
External Data is read only
External Tables
Benefits
Especially useful for
– ‘Describe it once, deploy it often’
– Scaling transparent intra-file parallelism without the
necessity to split input source
– Pipelining external data directly from the loading
into the transformation phase
Simplified Usage versus SQL*Loader
– Security control for external data inside the RDBMS
– No explicit OS access necessary
External Tables
Setup
Creation of Table Meta Data Oracle Server
– enhanced DDL command
CREATE TABLE PRODUCTS_EXT;

PRODUCTS_EXT
10, Sweater, .., 22.00, 5.00
PROD_ID PROD_NAME ... PRICE DISCOUNT
20, Skirt, ... ,25.50, 8.50
30, Trousers, …,50.00, 9.00 10 Sweater 22.00 5.00
20 Skirt 25.50 8.50
40, ... 30 Trousers 50.00 9.00
...

Use it
– Access with SQL, PL/SQL SELECT .. FROM
and Java PRODUCTS_EXT;
External Tables
Example
CREATE TABLE products_ext
( prod_id NUMBER, prod_name VARCHAR2(50), ... ,
price NUMBER(6,2), discount NUMBER(6,2) )
ORGANIZATION EXTERNAL -- declares table as external table
( TYPE loader_type -- access type of external table
DEFAULT DIRECTORY stage_dir --parameters similar to SQL*Loader
ACCESS PARAMETERS
( <records, fields similar to SQL*Loader>,
BADFILE ‘bad_products_ext’,
LOGFILE ‘log_products_ext’,
LOCATION (‘new_prod1.txt’, ‘ new_prod2.txt’)) -- two input files
PARALLEL 5 -- default degree of parallelism of 5
REJECT LIMIT 200;

INSERT /*+ APPEND */ INTO products


SELECT prod_id, prod_name, .., price as prod_list_price,
(price - discount) as min_price -- SQL calculation
FROM products_ext;

You might also like