Exforsys

Home arrow Reviews arrow Oracle Database Management Utilities

Oracle Utilities - External Tables Environment Setup

Author: Packt Publishing     Published on: 4th Jan 2010
Let's setup the environment

Let's create the demonstration user, and prepare its environment to create an External Table. The example that will be developed first refers to the External Table using the ORACLE_LOADER driver.

 

Ads

Sample Code
  1.  
  2.     create user EXTTABDEMO
  3.        identified by ORACLE
  4.        default tablespace USERS
  5.     alter user exttabdemo
  6.        quota unlimited on users
  7.     grant     CREATE SESSION,
  8.               CREATE TABLE,
  9.               CREATE PROCEDURE,
  10.               CREATE MATERIALIZED VIEW,
  11.               ALTER SESSION,
  12.               CREATE VIEW,
  13.               CREATE ANY DIRECTORY
  14.     to EXTTABDEMO
  15.  
Copyright exforsys.com


A simple formatted spool from this query will generate the required external table demonstration data. The original source table is the demonstration HR.EMPLOYEES table.

Sample Code
  1.  
  2.     select
  3.        EMPLOYEE_ID ','
  4.        DEPARTMENT_ID ','
  5.        FIRST_NAME ','
  6.        LAST_NAME ','
  7.        PHONE_NUMBER ','
  8.        HIRE_DATE ','
  9.        JOB_ID ','
  10.        SALARY ','
  11.        COMMISSION_PCT ','
  12.        MANAGER_ID ','
  13.        EMAIL
  14.     from       HR.EMPLOYEES
  15.     order by EMPLOYEE_ID
  16.  
Copyright exforsys.com


The above query will produce the following sample data:

The External Table directory is defined inside the database by means of a DIRECTORY object. This object is not validated at creation time, so the user must make sure the physical directory exists and the oracle OS user has read/write privileges on it.


$ mkdir $HOME/external_table_dest SQL> CREATE DIRECTORY EXTTABDIR AS '/home/oracle/external_table_dest';

 
Ads

The above example was developed in a Linux environment, on Windows platforms the paths will need to be changed to correctly reflect how Oracle has been set up.

Now, the first External Table can be created.



 
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