Datapump over loopback link #JoelKallmanDay
Recently I helped a client setting up a way to clone schemas. While thinking and researching, I came across a little documentation snippet I found useful:
The client was used to cloning a schema by datapump exporting the source schema to a dumpfile, then datapump importing from that dumpfile, renaming the schema in the process. All fine, except the need to have free storage on hand to hold this temporary dumpfile.
But datapump impdp also supports argument NETWORK_LINK to import things from a database link instead of from a dumpfile, eliminating the need for temporary storage.
Guess what - by using the global name of the database as NETWORK_LINK, the datapump import happens from the database itself.
So here's a simple oneliner to clone schema KIBEHA into a new schema KIBEHA2:
impdp system@freepdb1 network_link=freepdb1 schemas=kibeha remap_schema=kibeha:kibeha2
Just use the database global name in NETWORK_LINK, specify the source schema in SCHEMAS and use REMAP_SCHEMA to rename the source into the new target schema.
If you're cloning from a schema while people are working in the schema, you might need to add argument FLASHBACK_TIME to ensure consistency across the tables of the schema.
Which means you can even perform cloning where the cloned data is how the data looked back in time:
impdp system@freepdb1 network_link=freepdb1 schemas=kibeha remap_schema=kibeha:kibeha2 flashback_time=\"systimestamp - interval \'1\' hour\"
I showed it here using impdp - for the client I created a small schema cloning package doing the exact same thing with DBMS_DATAPUMP api.
So while you normally use datapump for data in or out of a database or between two databases, it is also possible with loopback database link to use datapump to copy data internally without leaving the database at all.
Happy #JoelKallmanDay, everybody.


Comments
Post a Comment