Use oracle_datapump to create an external table

Source: Internet
Author: User

1. Create an External table using datapump. The data comes from an internal entity table.

-- First create the scott. countries entity table for experiment

SQL> create table scott. countries (

2 country_id number,

3 country_name varchar2 (30 ),

4 country_reigion varchar2 (30)

5 );

 

Table created.

 

SQL> insert into scott. countries values (1, 'America ', 'America ');

 

1 row created.

 

SQL> insert into scott. countries values (2, 'China', 'zhuzhou ');

 

1 row created.

 

SQL> insert into scott. countries values (3, 'Japan ', 'dongjing ');

 

1 row created.

 

SQL> commit;

 

Commit complete.

-- Refer to the case where the official datapump creates an External table (whose data comes from an internal entity table), as shown below:

 

 

Create an External table after making the following changes (in red)

Create table scott. countries_ext

ORGANIZATION EXTERNAL

(

TYPE Oracle_DATAPUMP

Default directory dir -- generate the dmp file storage path

LOCATION ('countries _ ext. dmp ') -- generate the name of the external file

)

As select * FROM scott. countries; -- data comes FROM the entity table

-- Execute the statement above to create an external table

SQL> CREATE TABLE scott. countries_ext

2 ORGANIZATION EXTERNAL

3 (

4 TYPE ORACLE_DATAPUMP

5 default directory dir

6 LOCATION ('countries _ ext. dmp ')

7)

8 as select * FROM scott. countries;

 

Table created.

 

SQL> select * from scott. countries_ext;

 

COUNTRY_ID COUNTRY_NAME COUNTRY_REIGION

----------------------------------------------------------------------

1 AMERICA america

2 china zhuzhou

3. JAPAN dongjing

The external entity table is successfully created.

-- Check the directory where the dir external file is stored and check whether the countries_ext.dmp file is generated.

SQL> select * from dba_directories;

 

OWNER DIRECTORY_NAME DIRECTORY_PATH

--------------------------------------------------------------------------------
 
SYS DATA_PUMP_DIR/u01/app/oracle/product/10.2.0/db_1/rdbms/log/

Sys dir/home/oracle/dir

[Oracle @ gc1 dir] $ cd/home/oracle/dir

[Oracle @ gc1 dir] $ ls

COUNTRIES_EXT_14214.log countries_ext.dmp ldr. ctl ldr. log PROD_MY_12177.log PROD_MY_14213.log PROD_MY_14214.log prod_my.data
 
2. Create an External table with datapump from an external dmp File

-- The gc2 machine creates an External table to store the file directory, which is the same as the gc1

[Oracle @ gc2 dbs] $ cd/home/oracle

[Oracle @ gc2 ~] $ Mkdir dir

[Oracle @ gc2 ~] $ Cd dir

-- Create a file directory for the database and grant operation permissions to all users.

SQL> create directory dir as '/home/oracle/dir ';

 

Directory created.

 

SQL> grant all on directory dir to public;

 

Grant succeeded.

 

For more details, please continue to read the highlights on the next page:

Oracle 10 GB external table created

Oracle_loader type External table

Oracle_datapump type External table

Oracle External table maintenance

Oracle External table, or back up a single table to an external file

  • 1
  • 2
  • Next Page

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.