Ejemplo de importación (suponemos ya existe un export full completo de la bbdd ORCL) del esquema USER cambiandole el nombre a USER_PRU, donde usamos opciones de paralelismo y optimizamos el tiempo de creación de las constraints creándolas con la opción NOVALIDATE.
export ORACLE_SID=ORCL
------------------------------------------------------------------
-- GENERAMOS CONSTRAINTS.SQL
------------------------------------------------------------------
impdp userid=\'sys/sys as SYSDBA\' schemas=USER REMAP_SCHEMA=USER:USER_PRU dumpfile=expdp_ORCL_%U.dmp directory=EXPORTS_DIR INCLUDE=CONSTRAINT sqlfile=USER_PRU.constraints.sql
------------------------------------------------------------------
-- MODIFICAMOS FICHERO GENERADO, CON CLAUSULA NOVALIDATE
------------------------------------------------------------------
sed -e "s/ENABLE;/ENABLE NOVALIDATE;/g" USER_PRU.constraints.sql > USER_PRU.constraints.modificado.sql
------------------------------------------------------------------
-- IMPORT SIN CONSTRAINTS
------------------------------------------------------------------
impdp userid=\'sys/sys as SYSDBA\' full=n directory=EXPORTS_DIR dumpfile=expdp_ORCL_%U.dmp logfile=impdp_ORCL.log parallel=4 job_name=Imports_dp schemas=USER REMAP_SCHEMA=USER:USER_PRU EXCLUDE=CONSTRAINT,INDEX_STATISTICS
------------------------------------------------------------------
-- CARGAMOS LAS CONSTRAINTS
------------------------------------------------------------------
sqlplus / as SYSDBA @USER_PRU.constraints.modificado.sql
------------------------------------------------------------------
-- ANALIZAMOS
------------------------------------------------------------------
exec dbms_stats.gather_database_stats;
export ORACLE_SID=ORCL
------------------------------------------------------------------
-- GENERAMOS CONSTRAINTS.SQL
------------------------------------------------------------------
impdp userid=\'sys/sys as SYSDBA\' schemas=USER REMAP_SCHEMA=USER:USER_PRU dumpfile=expdp_ORCL_%U.dmp directory=EXPORTS_DIR INCLUDE=CONSTRAINT sqlfile=USER_PRU.constraints.sql
------------------------------------------------------------------
-- MODIFICAMOS FICHERO GENERADO, CON CLAUSULA NOVALIDATE
------------------------------------------------------------------
sed -e "s/ENABLE;/ENABLE NOVALIDATE;/g" USER_PRU.constraints.sql > USER_PRU.constraints.modificado.sql
------------------------------------------------------------------
-- IMPORT SIN CONSTRAINTS
------------------------------------------------------------------
impdp userid=\'sys/sys as SYSDBA\' full=n directory=EXPORTS_DIR dumpfile=expdp_ORCL_%U.dmp logfile=impdp_ORCL.log parallel=4 job_name=Imports_dp schemas=USER REMAP_SCHEMA=USER:USER_PRU EXCLUDE=CONSTRAINT,INDEX_STATISTICS
------------------------------------------------------------------
-- CARGAMOS LAS CONSTRAINTS
------------------------------------------------------------------
sqlplus / as SYSDBA @USER_PRU.constraints.modificado.sql
------------------------------------------------------------------
-- ANALIZAMOS
------------------------------------------------------------------
exec dbms_stats.gather_database_stats;
No hay comentarios:
Publicar un comentario