Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

import query

Status
Not open for further replies.

beechill4

Technical User
May 10, 2005
207
IE
Hi,

I have a test database which has the same tables as my production database.

Some data in the test tables is the same as the data in the production database, but both test and production have data which the other does nt have.

What is the best way to copy the production data into test but to hold onto the test data which is not in production?

Reagrds
 
I recommend the following scenario (presuming that you can "tnsping" the production database from the test database). Do all of the following while logged in as the TEST schema user:

1) Create a database link on the test database to the production database:
Code:
create database link MY_PROD
       connect to <prod_schema_name>
       identified by <prod_schema_password>
       using '<TNS alias for PROD instance>';

2) Create a table of consolidated information from both the PROD table and the TEST table:
Code:
CREATE TABLE TEST_HOLD AS
    SELECT * from <table_name>@MY_PROD
    UNION
    SELECT * from <table_name>;

3) Empty out the TEST table:
Code:
TRUNCATE TABLE <table_name>;

4) Load the consolidated information into the TEST table:
Code:
INSERT INTO <table_name> SELECT * from TEST_HOLD;
COMMIT;
Let us know if this satisfies your need.

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I provide low-cost, remote Database Administration services: www.dasages.com]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top