Oracle Illustrated

Feb 21 2010   7:18AM GMT

Migrating from 9i to 11g – External table

Lakshmi Venkatesh Profile: Lakshmi Venkatesh

Prior to Oracle 9i we can only read from external tables – from Oracle 10g we can write to external table !! ie., LOADING & UNLOADING is possible via external tables.
Lets take a look at a quick example for unloading part -
create or replace directory ext_dir as ‘F:\app\Luxananda\oradata\lux’

CREATE TABLE external_test
ORGANIZATION EXTERNAL
(TYPE ORACLE_DATAPUMP DEFAULT DIRECTORY ext_dir LOCATION (‘DEPT.DAT’))
reject limit unlimited
AS select * from dept

As we have not specified the log file it got automatically created:

EXTERNAL_TEST_2672_4200.log

SQL> select * from external_test ;

DEPTNO DNAME LOC
———- ———- ———
380 ACCOUNTING SINGAPORE
630 IT SINGAPORE
120 RESEARCH SINGAPORE
320 OPERATIONS SINGAPORE
550 SALES SINGAPORE

How does DEPT.DAT contents look like ? – Its in XML Format !!

Now, lets query Select dbms_metadata.get_ddl(‘TABLE’,’EXTERNAL_TEST’) from dual; -> returns the Table creation syntax.

DBMS_METADATA.GET_DDL(‘TABLE’,’EXTERNAL_TEST’)
CREATE TABLE “SYSTEM”.”EXTERNAL_TEST”
( “DEPTNO” NUMBER,
“DNAME” VARCHAR2(10),
“LOC” CHAR(9)
)
ORGANIZATION EXTERNAL
( TYPE ORACLE_DATAPUMP
DEFAULT DIRECTORY “EXT_DIR”
LOCATION
( ‘DEPT.DAT’
)
) REJECT LIMIT UNLIMITED

Now, if we create another external table in some other environment and make it access the same table we would be able to read it from the file.

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: