Difference between revisions of "(Re)create user/schema using DataPump"
| Line 14: | Line 14: | ||
and/or maybe one or more of the following: | and/or maybe one or more of the following: | ||
| − | + | <pre> | |
| − | + | exclude=grants | |
| − | + | tables=(<schema name>.<table name>) | |
| + | remap_tablespace=old:new | ||
| + | </pre> | ||
Finally, recompile all invalid objects: | Finally, recompile all invalid objects: | ||
exec utl_recomp.recomp_serial(); | exec utl_recomp.recomp_serial(); | ||
Revision as of 22:57, 26 December 2012
If the user does not yet exist on the destination database, just import it using the procedure outlined here.
If however, the user(schema) already exists, it will have to be dropped and re-created before the data can be imported.
But, before dropping the schema, run this script to generate the correct DDL beforehand!
After this DDL has been run and the results stored, the following command can be executed:
drop user <schema name> cascade;
Now, recreate the schema with the above-mentioned DDL
The dumpfile (or a part thereof) can now be imported to fill up the currently empty schema:
impdp <usr>/<pwd> parfile=schema.par
where schema.par would look like this:
directory=DP_IMPORT dumpfile=<db_name>_DP.DMP schemas=(<schema name>)
and/or maybe one or more of the following:
exclude=grants tables=(<schema name>.<table name>) remap_tablespace=old:new
Finally, recompile all invalid objects:
exec utl_recomp.recomp_serial(); or exec utl_recomp.recomp_parallel(4); or @?\rdbms\admin\utlrp.sql or @?\rdbms\admin\utlprp.sql(4)
and the grants are different on the destination database than they were on the source database, they should be retained. This can be accomplished by excluding grants when importing.
The schema should ideally be checked beforehand that it does not own objects like 'type's that may exist elsewhere...