Copy data from one schema to a different schema
I want to copy data from one schema (let's call it PROD) to another (let's call it TEST) for testing purposes.
I already have these two schemas in the database. The issue is the two schema are not exactly the same: TEST is incomplete regarding PROD.
I thought I could do this:
exp userid=xxx/xxx file=my_db.dmp
drop the TEST schema, re-create the TEST user in the DB, then
imp userid=xxx/xxx file=my_db.dmp
log=imp.log fromuser=PROD touser=TEST
Is it a correct way to do this or is there a simpler way?
The steps you described above are among the simplest. The nice thing about using export/import for this task is that you get an entire copy of the schema. You could use INSERT SELECT statements to copy the data, but then you might miss other schema objects. And INSERT SELECT won't modify the table structure either. Your steps above are how I tackle this task.
This was first published in April 2007