Procedimiento para exportación/importación mediante Datapump via dblink, que debe ser creado en la base de datos Destino:
CREATE OR REPLACE PROCEDURE RECUPERA
( source_schema in varchar2,
destination_schema in varchar2,
network_link in varchar2 default 'DBLINK')
as
JobHandle number;
js varchar2(9);
q varchar2(1) := chr(39);
BEGIN
JobHandle := dbms_datapump.open ('IMPORT','SCHEMA',network_link);
dbms_datapump.metadata_filter ( JobHandle,'SCHEMA_LIST',q||source_schema||q);
dbms_datapump.metadata_remap ( JobHandle,'REMAP_SCHEMA',source_schema,destination_schema);
dbms_datapump.set_parameter ( JobHandle,'TABLE_EXISTS_ACTION','REPLACE' );
dbms_datapump.start_job( JobHandle);
dbms_datapump.wait_for_job( JobHandle, js);
end;
/
Ejecución:
exec recupera('ESQUEMA_ORIGEN', 'ESQUEMA_DESTINO', 'DB_LINK_A_ORIGEN');