How to duplicate a database schema
843937Mar 7 2011 — edited Mar 7 2011You can do it with Oracle Datapump (expdp/impdp).
1. Check if there is an oracle directory object on a drive with enough space:
select * from all_directories;]
If not, create one:
create directory g_dump as 'g:\oracle\dump';]
2. Export schema:
expdp system/*** directory=g_dump dumpfile=<File Name> logfile=exp_<file name>
schemas=(schema_name1,schema_name2)]
3. Optional: If you are copying schemas to another server, repeat step 1 on the destination server, then
copy .DMP file there. Keep folder name and directory object same as on the source server, if possible.
4. Import into a new schema:
impdp system/*** directory=g_dump dumpfile==<File Name> logfile=exp_<file name>
remap_schema=<User name>:new_<user name> remap_schema=<User name>:new_<user name>]
Use remap_schema parameter for every user you want to rename. Omit this parameter if you do not
rename users (copying schemas to another database).
If you want to import into separate tablespaces, create these tablespaces, and specify this in the impdp
command line:
remap_tablespace=<tablespace name>:new_tbs remap_tablespace=<tablespace name>:new_tbs]
Note: If you are trying to reimport the schema into the original database
but you are remapping the tablespace, your remap tablespace must read:
remap_tablespace:whatever_tablespace_it_was_in_before:tablespace_you_want_it_in_now]