导读:
  前几天都是用Package来完成streams的配置,但在管理上用OEM会感觉更为直观,当然对所有相关的Package很了解的话,也就都差不多了。在9i的OEM中看上去对streams的功能还不是很强。只是简单的一些应用。下面有时间就要搞10gR2,想跳过10gR1的。下面帖一个在OEM建立单表复制的过程脚本。
  源数据库: GATES
  目标数据库: CLONE
  1.设置操作
  - Turn on supplemental logging and switch log file at source database.
  - Create and set default tablespace for LogMiner at source database.
  - 在源数据库中捕获以下各表, 然后传播并将更改应用于目标数据库。
  "SCOTT"."BONUS"
  2.导出/导入操作
  - 导出从源数据库选择的所有对象。
  - 将它们导入到目标数据库。
  3.启动操作
  - 首先在目标数据库中启动应用进程。
  - 在源数据库中启动捕获进程。
  -- Setup Operations:
  
  
  用Oracle Streams wizard生成配置脚本
  REM
  
  用Oracle Streams wizard生成配置脚本
  REM The following sections setup streams at the destination database
  
  用Oracle Streams wizard生成配置脚本
  REM
  
  用Oracle Streams wizard生成配置脚本
  ACCEPT dest_strmadmin_passwd PROMPT '请输入目标数据库
  
  用Oracle Streams wizard生成配置脚本
  CLONE 中的用户 STRMADMIN 的口令 : 'HIDE
  
  用Oracle Streams wizard生成配置脚本
  connect STRMADMIN/&dest_strmadmin_passwd@CLONE
  
  用Oracle Streams wizard生成配置脚本
  
  
  用Oracle Streams wizard生成配置脚本
  REM
  
  用Oracle Streams wizard生成配置脚本
  REM Addapply rules fortables at the destination database
  
  用Oracle Streams wizard生成配置脚本
  REM
  
  用Oracle Streams wizard生成配置脚本
  BEGIN
  
  用Oracle Streams wizard生成配置脚本
  DBMS_STREAMS_ADM.ADD_TABLE_RULES(
  
  用Oracle Streams wizard生成配置脚本
  table_name =>'"SCOTT"."BONUS"',
  
  用Oracle Streams wizard生成配置脚本
  streams_type =>'APPLY',
  
  用Oracle Streams wizard生成配置脚本
  streams_name =>'STRMADMIN_GATES_VONGATES_',
  
  用Oracle Streams wizard生成配置脚本
  queue_name =>'"STRMADMIN"."STREAMS_QUEUE"',
  
  用Oracle Streams wizard生成配置脚本
  include_dml =>true,
  
  用Oracle Streams wizard生成配置脚本
  include_ddl =>true,
  
  用Oracle Streams wizard生成配置脚本
  source_database =>'GATES.VONGATES.COM');
  
  用Oracle Streams wizard生成配置脚本
  END;
  
  用Oracle Streams wizard生成配置脚本
  /
  
  用Oracle Streams wizard生成配置脚本
  
  
  用Oracle Streams wizard生成配置脚本
  REM
  
  用Oracle Streams wizard生成配置脚本
  REM The following sections setup streams at the source database
  
  用Oracle Streams wizard生成配置脚本
  REM
  
  用Oracle Streams wizard生成配置脚本
  ACCEPT source_strmadmin_passwd PROMPT '请输入源数据库
  
  用Oracle Streams wizard生成配置脚本
  GATES 中的用户 STRMADMIN 的口令 : 'HIDE
  
  用Oracle Streams wizard生成配置脚本
  connect SYS/&source_dba_passwd@GATESasSYSDBA
  
  用Oracle Streams wizard生成配置脚本
  
  
  用Oracle Streams wizard生成配置脚本
  REM
  
  用Oracle Streams wizard生成配置脚本
  REM Turn onsupplemental logging
  
  用Oracle Streams wizard生成配置脚本
  REM
  
  用Oracle Streams wizard生成配置脚本
  ALTERDATABASEADDSUPPLEMENTAL LOGDATA (PRIMARYKEY,UNIQUEINDEX)
  
  用Oracle Streams wizard生成配置脚本
  COLUMNS;
  
  用Oracle Streams wizard生成配置脚本
  
  
  用Oracle Streams wizard生成配置脚本
  REM
  
  用Oracle Streams wizard生成配置脚本
  REM Switch logfile
  
  用Oracle Streams wizard生成配置脚本
  REM
  
  用Oracle Streams wizard生成配置脚本
  ALTERSYSTEM SWITCH LOGFILE;
  
  用Oracle Streams wizard生成配置脚本
  
  
  用Oracle Streams wizard生成配置脚本
  REM
  
  用Oracle Streams wizard生成配置脚本
  REM Createlogminer tablespace
  
  用Oracle Streams wizard生成配置脚本
  REM
  
  用Oracle Streams wizard生成配置脚本
  CREATETABLESPACE LOGMNRTS DATAFILE 'logmnrts_GATES.dbf'
  
  用Oracle Streams wizard生成配置脚本
  SIZE 25M REUSE
  
  用Oracle Streams wizard生成配置脚本
  AUTOEXTEND ONMAXSIZE UNLIMITED;
  
  用Oracle Streams wizard生成配置脚本
  
  
  用Oracle Streams wizard生成配置脚本
  REM
  
  用Oracle Streams wizard生成配置脚本
  REM Setlogminer tablespace
  
  用Oracle Streams wizard生成配置脚本
  REM
  
  用Oracle Streams wizard生成配置脚本
  BEGIN
  
  用Oracle Streams wizard生成配置脚本
  DBMS_LOGMNR_D.SET_TABLESPACE('LOGMNRTS');
  
  用Oracle Streams wizard生成配置脚本
  END;
  
  用Oracle Streams wizard生成配置脚本
  /
  
  用Oracle Streams wizard生成配置脚本
  connect STRMADMIN/&source_strmadmin_passwd@GATES
  
  用Oracle Streams wizard生成配置脚本
  
  
  用Oracle Streams wizard生成配置脚本
  REM
  
  用Oracle Streams wizard生成配置脚本
  REM Addcapture rules fortables at the source database
  
  用Oracle Streams wizard生成配置脚本
  REM
  
  用Oracle Streams wizard生成配置脚本
  BEGIN
  
  用Oracle Streams wizard生成配置脚本
  DBMS_STREAMS_ADM.ADD_TABLE_RULES(
  
  用Oracle Streams wizard生成配置脚本
  table_name =>'"SCOTT"."BONUS"',
  
  用Oracle Streams wizard生成配置脚本
  streams_type =>'CAPTURE',
  
  用Oracle Streams wizard生成配置脚本
  streams_name =>'STRMADMIN_CAPTURE',
  
  用Oracle Streams wizard生成配置脚本
  queue_name =>'"STRMADMIN"."STREAMS_QUEUE"',
  
  用Oracle Streams wizard生成配置脚本
  include_dml =>true,
  
  用Oracle Streams wizard生成配置脚本
  include_ddl =>true,
  
  用Oracle Streams wizard生成配置脚本
  source_database =>'GATES.VONGATES.COM');
  
  用Oracle Streams wizard生成配置脚本
  END;
  
  用Oracle Streams wizard生成配置脚本
  /
  
  用Oracle Streams wizard生成配置脚本
  
  
  用Oracle Streams wizard生成配置脚本
  REM
  
  用Oracle Streams wizard生成配置脚本
  REM Addpropagation rules fortables at the source database
  
  用Oracle Streams wizard生成配置脚本
  REM
  
  用Oracle Streams wizard生成配置脚本
  BEGIN
  
  用Oracle Streams wizard生成配置脚本
  DBMS_STREAMS_ADM.ADD_TABLE_PROPAGATION_RULES(
  
  用Oracle Streams wizard生成配置脚本
  table_name =>'"SCOTT"."BONUS"',
  
  用Oracle Streams wizard生成配置脚本
  streams_name =>'STRMADMIN_PROPAGATE',
  
  用Oracle Streams wizard生成配置脚本
  source_queue_name =>'"STRMADMIN"."STREAMS_QUEUE"',
  
  用Oracle Streams wizard生成配置脚本
  destination_queue_name =>'"STRMADMIN"."STREAMS_QUEUE"@CLONE.VONGATES.COM',
  
  用Oracle Streams wizard生成配置脚本
  include_dml =>true,
  
  用Oracle Streams wizard生成配置脚本
  include_ddl =>true,
  
  用Oracle Streams wizard生成配置脚本
  source_database =>'GATES.VONGATES.COM');
  
  用Oracle Streams wizard生成配置脚本
  END;
  
  用Oracle Streams wizard生成配置脚本
  /
  
  用Oracle Streams wizard生成配置脚本
  --Export/Import Operations:
  
  用Oracle Streams wizard生成配置脚本
  expUSERID="STRMADMIN"@GATESTABLES="SCOTT"."BONUS"
  
  用Oracle Streams wizard生成配置脚本
  FILE=tables.dmp GRANTS=Y ROWS=Y LOG=exportTables.log
  
  用Oracle Streams wizard生成配置脚本
  OBJECT_CONSISTENT=Y INDEXES=Y
  
  用Oracle Streams wizard生成配置脚本
  
  
  用Oracle Streams wizard生成配置脚本
  imp USERID="STRMADMIN"@CLONEFULL=Y CONSTRAINTS=Y FILE=tables.dmp
  
  用Oracle Streams wizard生成配置脚本
  IGNORE=Y GRANTS=Y ROWS=Y COMMIT=Y LOG=importTables.log
  
  用Oracle Streams wizard生成配置脚本
  STREAMS_CONFIGURATION=Y STREAMS_INSTANTIATION=Y
  
  用Oracle Streams wizard生成配置脚本
  
  
  用Oracle Streams wizard生成配置脚本
  --Startup Operations:
  
  用Oracle Streams wizard生成配置脚本
  ACCEPT dest_strmadmin_passwd PROMPT '请输入目标数据库
  
  用Oracle Streams wizard生成配置脚本
  CLONE 中的用户 STRMADMIN 的口令 : 'HIDE
  
  用Oracle Streams wizard生成配置脚本
  connect STRMADMIN/&dest_strmadmin_passwd@CLONE
  
  用Oracle Streams wizard生成配置脚本
  
  
  用Oracle Streams wizard生成配置脚本
  REM
  
  用Oracle Streams wizard生成配置脚本
  REM Start apply process at the destination database
  
  用Oracle Streams wizard生成配置脚本
  REM
  
  用Oracle Streams wizard生成配置脚本
  DECLARE
  
  用Oracle Streams wizard生成配置脚本
  v_started number;
  
  用Oracle Streams wizard生成配置脚本
  BEGIN
  
  用Oracle Streams wizard生成配置脚本
  SELECTdecode(status, 'ENABLED', 1, 0) INTOv_started
  
  用Oracle Streams wizard生成配置脚本
  FROMDBA_APPLY WHEREAPPLY_NAME ='STRMADMIN_GATES_VONGATES_';
  
  用Oracle Streams wizard生成配置脚本
  
  
  用Oracle Streams wizard生成配置脚本
  if(v_started =0) then
  
  用Oracle Streams wizard生成配置脚本
  DBMS_APPLY_ADM.START_APPLY(apply_name =>'STRMADMIN_GATES_VONGATES_');
  
  用Oracle Streams wizard生成配置脚本
  endif;
  
  用Oracle Streams wizard生成配置脚本
  END;
  
  用Oracle Streams wizard生成配置脚本
  /
  
  用Oracle Streams wizard生成配置脚本
  
  
  用Oracle Streams wizard生成配置脚本
  ACCEPT source_strmadmin_passwd PROMPT '请输入源数据库
  
  用Oracle Streams wizard生成配置脚本
  GATES 中的用户 STRMADMIN 的口令 : 'HIDE
  
  用Oracle Streams wizard生成配置脚本
  connect STRMADMIN/&source_strmadmin_passwd@GATES
  
  用Oracle Streams wizard生成配置脚本
  
  
  用Oracle Streams wizard生成配置脚本
  DECLARE
  
  用Oracle Streams wizard生成配置脚本
  v_started number;
  
  用Oracle Streams wizard生成配置脚本
  BEGIN
  
  用Oracle Streams wizard生成配置脚本
  SELECTdecode(status, 'ENABLED', 1, 0) INTOv_started
  
  用Oracle Streams wizard生成配置脚本
  FROMDBA_CAPTURE WHERECAPTURE_NAME ='CAPTURE';
  
  用Oracle Streams wizard生成配置脚本
  if(v_started =0) then
  
  用Oracle Streams wizard生成配置脚本
  DBMS_CAPTURE_ADM.START_CAPTURE(capture_name =>'CAPTURE');
  
  用Oracle Streams wizard生成配置脚本
  endif;
  
  用Oracle Streams wizard生成配置脚本
  END;
  
  用Oracle Streams wizard生成配置脚本
  /
  
  用Oracle Streams wizard生成配置脚本
  
  

本文转自
http://oracle.itpub.net/post/20957/146515

相关文章: