How to Refresh the Local Tables Using DataPump API (Doc ID 1073046.1)

Last updated on NOVEMBER 28, 2016

Applies to:

Oracle Database - Enterprise Edition - Version 10.2.0.1 to 11.2.0.1 [Release 10.2 to 11.2]
Information in this document applies to any platform.

Goal

You have two databases (one local and one remote) and intend to refresh some local tables with data from remote tables. To demonstrate this the following environment is created:

Remote database (source)

connect / as sysdba

-- test user
create user test identified by test default tablespace users temporary tablespace temp;
grant connect, resource to test;

-- create objects in test schema
connect test/test

-- test tables
create table a_tab
(
   id   number,
   text varchar2(50)
);

create table b_tab
(
   id   number,
   text varchar2(50)
);

-- populate test tables
insert into a_tab values (1, 'Remote schema, table A_TAB - Row 1');
insert into a_tab values (2, 'Remote schema, table A_TAB - Row 2');
insert into b_tab values (1, 'Remote schema, table B_TAB - Row 1');
insert into b_tab values (2, 'Remote schema, table B_TAB - Row 2');
commit;

-- create table that contains the
-- object names to be refreshed in
-- local database
create table transfer_objects
(
   owner       varchar2(30),
   table_name  varchar2(30),
   object_type varchar2(30)
);

-- these tables will be refreshed in local database
insert into transfer_objects values ('TEST', 'A_TAB', 'TABLE');
insert into transfer_objects values ('TEST', 'B_TAB', 'TABLE');
commit;

Local database (target)

connect / as sysdba

-- directory used to write DataPump log files
create directory refresh as '/tmp';

-- test user
create user test identified by test default tablespace users temporary tablespace temp;
grant connect, resource, create database link to test;
grant read, write on directory refresh to test;

-- objects in test schema
connect test/test

-- database link from local to remote
create database link link_to_remote connect to test identified by test using '<TNS alias to remote>';

-- local test tables
create table a_tab
(
   id   number,
   text varchar2(50)
);

create table b_tab
(
   id   number,
   text varchar2(50)
);

-- populate test tables
insert into a_tab values (1, 'Local schema, table A_TAB - Row 1');
insert into b_tab values (1, 'Local schema, table B_TAB - Row 1');
commit;

Solution

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms