How to Refresh the Local Tables Using DataPump API Started From Another Schema (Doc ID 1084128.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. You start the DataPump API connected as DBA user from another schema. 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;

-- DBA user
create user dbs_usr identified by dba_usr default tablespace users temporary tablespace temp;
grant connect, resource, dba to dba_usr;

-- 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 in schema DBA_USR that
-- contains the object names to be
-- refreshed in local database

connect dba_usr/dba_usr

create table transfer_objects
(
   owner       varchar2(30),
   table_name  varchar2(30),
   object_type varchar2(30)
);

-- only here specified tables will be refreshed in local database
insert into transfer_objects values ('EEN_RPT', 'B_TAB', 'TABLE');
commit;

Local database (target)

connect / as sysdba

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

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

-- DBA user
create user dba_usr identified by dba_usr default tablespace users temporary tablespace temp;
grant connect, resource, dba to dba_usr;
grant read, write on directory refresh to dba_usr;

-- objects in test schema
connect test/test

-- 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;

connect dba_usr/dba_usr

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

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