Exforsys

Home arrow Reviews arrow Oracle Database Management Utilities

Oracle Utilities - Unloading data to External Tables

Author: Packt Publishing     Published on: 4th Jan 2010

The driver used to unload data to an External Table is the ORACLE_DATAPUMP access driver. It dumps the contents of a table in a binary proprietary format file. This way you can exchange data with other 10g and higher databases in a preformatted way to meet the other database's requirements. Unloading data to an External Table doesn't make it updateable, the tables are still limited to being read only.

 

Ads

Let's unload the EMPLOYEES table to an External Table:

Sample Code
  1.  
  2.    create table dp_employees
  3.       organization external(
  4.               type oracle_datapump
  5.              default directory EXTTABDIR
  6.              location ('dp_employees.dmp')
  7.       )
  8.    as
  9.       select * from employees
  10.  
Copyright exforsys.com


This creates a table named DP_EMPLOYEES, located at the specified EXTTABDIR directory and with a defined OS file name.

In the next example, at a different database a new DP_EMPLOYEES table is created, this table uses the already unloaded data by the first database. This DP_EMPLOYEES External Table is created on the 11g database side.

Sample Code
  1.  
  2.     create table dp_employees(
  3.     EMPLOYEE_ID        NUMBER(6),
  4.     FIRST_NAME VARCHAR2(20),
  5.     LAST_NAME VARCHAR2(25),
  6.     EMAIL              VARCHAR2(25),
  7.     PHONE_NUMBER       VARCHAR2(20),
  8.     HIRE_DATE DATE,
  9.     JOB_ID             VARCHAR2(10),
  10.     SALARY             NUMBER(8,2),
  11.     COMMISSION_PCT     NUMBER(2,2),
  12.     MANAGER_ID NUMBER(6),
  13.     DEPARTMENT_ID      NUMBER(4)
  14.     )
  15.     organization external
  16.     (
  17.        type oracle_datapump
  18.        default directory EXTTABDIR
  19.        location ('dp_employees.dmp')
  20.     )
  21.  
Copyright exforsys.com


This table can already read in the unloaded data from the first database. The second database is a regular 11g database. So this shows the inter-version upward compatibility between a 10g and an 11g database.

 

Ads


Sample Code
  1.  
  2. SQL> select count(*) from dp_employees
  3.   COUNT(*)
  4. ----------
  5.          107
  6.  
Copyright exforsys.com




 
This tutorial is part of a Oracle Database Management Utilities tutorial series. Read it from the beginning and learn yourself.

Oracle Database Management Utilities

 

Comments