Created
November 7, 2016 10:15
-
-
Save akapitula/0c98c2b788c0e9835c2630c68e9690fe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// to export and import Oracle database user as an alternative to old imp/exp utility can be used next commands: | |
// In sql editor run: | |
// export dump file in Oracle storage | |
DECLARE | |
hdnl NUMBER; | |
BEGIN | |
hdnl := DBMS_DATAPUMP.open( operation => 'EXPORT', job_mode => 'SCHEMA', job_name=>null); | |
DBMS_DATAPUMP.ADD_FILE( handle => hdnl, filename => 'dumpfile.dump', directory => 'DATA_PUMP_DIR', filetype => dbms_datapump.ku$_file_type_dump_file); | |
DBMS_DATAPUMP.add_file( handle => hdnl, filename => 'dumplog.log', directory => 'DATA_PUMP_DIR', filetype => dbms_datapump.ku$_file_type_log_file); | |
DBMS_DATAPUMP.METADATA_FILTER(hdnl,'SCHEMA_EXPR','IN (''EXPORTED DB USER'')'); | |
DBMS_DATAPUMP.start_job(hdnl); | |
END; | |
// In sqlplus run: | |
// import dump file | |
impdp {user}/{password}@{host}/{SID} remap_schema={DUMP DB USER}:{NEW USER (can not exist)} directory=DATA_PUMP_DIR dumpfile=dumpfile.dump logfile=import.log | |
// In sql editor run: | |
// Remove imported dump file in case of succedfull import: | |
BEGIN utl_file.fremove('DATA_PUMP_DIR','dumpfile.dump'); END; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment