My Oracle Support Banner

How to Refresh the Local Tables Using DataPump API Started From Another Schema (Doc ID 1084128.1)

Last updated on SEPTEMBER 26, 2019

Applies to:

Oracle Database - Enterprise Edition - Version 10.2.0.1 to 11.2.0.1 [Release 10.2 to 11.2]
Oracle Database Cloud Schema Service - Version N/A and later
Oracle Database Exadata Cloud Machine - Version N/A and later
Oracle Database Exadata Express Cloud Service - Version N/A and later
Oracle Cloud Infrastructure - Database Service - Version N/A and later
Information in this document applies to any platform.
NOTE: In the images and/or the document content below, the user information and data used represents fictitious data.
Any similarity to actual persons, living or dead, is purely coincidental and not intended in any manner.

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 <PASSWORD1> default tablespace users temporary tablespace temp;
grant connect, resource to test;

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

-- create objects in test schema
connect test/<PASSWORD1>

-- 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/<PASSWORD2>

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 <PASSWORD1> default tablespace users temporary tablespace temp;
grant connect, resource to test;

-- DBA user
create user dba_usr identified by <PASSWORD2> 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/<PASSWORD1>

-- 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/<PASSWORD2>

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

Solution

To view full details, sign in with your My Oracle Support account.

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


In this Document
Goal
Solution
References

My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.