我试图将数据库从转储导入oracle,一旦导入完成,我想对该数据进行一些更改。什么是最好的方法来实现这一目标?下面的脚本将导入转储文件并重新映射架构,但作业似乎是fork,并且更改尝试在datapump完成之前运行。我是Oracle新手,试图在Oracle SE数据库上运行它。提前感谢所有建议/指示。
begin
declare
h1 NUMBER;
h1_status varchar2(200);
begin
h1 := dbms_datapump.open (operation => 'IMPORT', job_mode => 'FULL', job_name => 'COPYBACK_IMPORT', version => 'COMPATIBLE');
dbms_datapump.add_file(handle => h1, filename => 'COPYBACK.LOG', directory => 'DATA_PUMP_DIR', filetype => DBMS_DATAPUMP.KU$_FILE_TYPE_LOG_FILE);
dbms_datapump.add_file(handle => h1, filename => 'COPYBACK.LOG', directory => 'DATA_PUMP_DIR', filetype => 3);
dbms_datapump.set_parameter(handle => h1, name => 'KEEP_MASTER', value => 0);
dbms_datapump.add_file(handle => h1, filename => 'SOME_DB_DUMP.dmp', directory => 'DATA_PUMP_DIR', filetype => DBMS_DATAPUMP.KU$_FILE_TYPE_DUMP_FILE);
dbms_datapump.metadata_remap(handle => h1, name => 'REMAP_TABLESPACE', old_value => 'SOME_TS', value => 'USERS');
dbms_datapump.metadata_remap(handle => h1, name => 'REMAP_SCHEMA', old_value => 'SOMETHING', value => 'DBADMIN');
dbms_datapump.set_parameter(handle => h1, name => 'INCLUDE_METADATA', value => 1);
dbms_datapump.set_parameter(handle => h1, name => 'DATA_ACCESS_METHOD', value => 'AUTOMATIC');
dbms_datapump.set_parameter(handle => h1, name => 'REUSE_DATAFILES', value => 0);
dbms_datapump.set_parameter(handle => h1, name => 'TABLE_EXISTS_ACTION', value => 'REPLACE');
dbms_datapump.start_job(handle => h1, skip_current => 0, abort_step => 0);
dbms_datapump.wait_for_job(handle => h1, job_state => h1_status);
dbms_datapump.detach(handle => h1);
end;
begin
update DBADMIN.users set passwd = 'new_passwd', p_passwordencoding = 'plain' where p_uid = 'some_user';
delete from DBADMIN.props where name='system.locked';
end;
end;
/
答案 0 :(得分:0)
我建议使用来自操作系统的impdp而不是包,然后创建一个批处理或sh文件来执行带有所需参数的impdp(你可以使用参数文件),如果一切都是好的,执行更新。