-- VER DIRETORIOS - ORIGEM - DESTINO
select * from dba_directories


============ EXPORT SCHEMAS = PRD =======================================================

-- CRIAR PARFILE
vi expdp_PRDCRIT_FIES_160218.par

userid='/ as sysdba'
directory=BACKUP_DB_EXPDP
DUMPFILE=expdp_FIES_HMG_%U.dmp
LOGFILE=expdp_FIES_HMG.log
SCHEMAS=FIES_GLOBAL,FIES_SEGURANCA,FIES_PREINSCRICAO,FIES_AUDITORIA,FIES_REMANESCENTE,FIES_FINANCIAMENTO
PARALLEL=9

--fazer dump expdp 
expdp parfile=/bkp_prdora_exa/backup_db_expdp/expdp_SISU_231118.par


=========== DESTINO =============================================================================================

=== matar sess?es====
SELECT DISTINCT 'ALTER SYSTEM KILL session '''||s.sid||','||S.SERIAL#||',@'||S.INST_ID||''' immediate;' 
FROM gv$session s --gv$lock l
,GV$SQL SA
WHERE username LIKE  ('%FIES_PREINSCRICAO%');

============ DROPAR OBJETOS DESTINO = HMG ========================================================

DROP USER FIES_SEGURANCA CASCADE
DROP USER FIES_GLOBAL CASCADE
DROP USER FIES_AUDITORIA CASCADE
DROP USER FIES_PREINSCRICAO CASCADE
DROP USER FIES_REMANESCENTE CASCADE
DROP USER FIES_FINANCIAMENTO CASCADE 


========== MOVE DESTINO ===================================================================
scp expdp_FIES_HMG.dmp root@10.94.0.30:/mnt/backup/backup_db/backup_trabalho/DSV_dumps

======== setar instancia ==============================
ps -ef | grep pmon
export ORACLE_SID = hmgora2
echo $ORACLE_SID


============ IMPORTAR SHCEMAS DESTINO = HMG =================================================
create impdp.par:

userid='/ as sysdba'
directory=BKPTRABALHO
DUMPFILE=expdp_FIES_HMG_%U.dmp
LOGFILE=impdp_FIES_HMG.log
SCHEMAS=
FIES_SEGURANCA,
FIES_GLOBAL,
FIES_AUDITORIA, 
FIES_PREINSCRICAO, 
FIES_REMANESCENTE, 
FIES_FINANCIAMENTO

============== EXECUTA IMPDP ===================================================================
sqlplus / as sysdba
impdp parfile=/mnt/backup/backup_db/backup_trabalho/parfile/impdp_FIES_HMG.par 

hostgator