以下是实践中大事务处理过程:
1) 停止流
-- 源数据库停止Capture进程
connect strmadmin
BEGIN
DBMS_CAPTURE_ADM.STOP_CAPTURE(
capture_name => 'capture1');
END;
/
-- 目标数据库停止Apply进程
connect strmadmin
begin
dbms_apply_adm.stop_apply(
apply_name => 'APPLY1');
end;
/
2) 在源库上执行大事务
3) exp imp 获得目标表初始scn
exp USERID=u1/p1 tables=(t1,t2) OBJECT_CONSISTENT=y FILE=tables.dmp
scp tables.dmp 10.10.10.1:.
sqlplus u1/p1
drop table t1 purge;
drop table t2 purge;
imp USERID=u1/p1 tables=(t1,t2) FILE=tables.dmp STREAMS_INSTANTIATION=y
4) DBMS_APPLY_ADM设置SCN
DECLARE
iscn NUMBER; -- Variable to hold instantiation SCN value
BEGIN
iscn := DBMS_FLASHBACK.GET_SYSTEM_CHANGE_NUMBER();
[email protected](
source_object_name => 'u1.t1',
source_database_name => 'db1',
instantiation_scn => iscn);
[email protected](
source_object_name => 'u1.t1',
source_database_name => 'db1',
instantiation_scn => iscn);
END;
/
5) 启动Stream
-- 目标数据库启动应用进程
connect strmadmin
begin
dbms_apply_adm.start_apply(
apply_name => 'APPLY1');
end;
/
-- 源数据库启动捕获进程
connect strmadmin
BEGIN
DBMS_CAPTURE_ADM.START_CAPTURE(
capture_name => 'capture1');
END;
/
exec dbms_apply_adm.delete_all_errors(apply_name => 'APPLY1');