Oracle GoldenGate系統之----單向同步資料表(續)

wailon發表於2013-12-04

源端與目標端的表結構欄位名不一致時,需要在目標端使用COLMAP指定。

目標端
-- 修改REPLICAT程式如下

GGSCI (dgrac) 1> edit param reps1

replicat reps1
setenv(NLS_LANG=AMERICAN_AMERICA.ZHS16GBK)
userid lrj@ogg, password lrj
assumetargetdefs
reperror default,discard
discardfile /u01/app/ogg/dirout/reps1.dsc,append,megabytes 100
--map lrj.s1,target lrj.s1;
colmap(usedefaults,"ENAME" = "USERNAME");
~
 
"dirprm/reps1.prm" 8L, 261C written


GGSCI (dgrac) 2> view param reps1

replicat reps1
setenv(NLS_LANG=AMERICAN_AMERICA.ZHS16GBK)
userid lrj@ogg, password lrj
assumetargetdefs
reperror default,discard
discardfile /u01/app/ogg/dirout/reps1.dsc,append,megabytes 100
--map lrj.s1,target lrj.s1;
map lrj.s1,target lrj.s1 &
colmap(usedefaults,"ENAME" = "USERNAME");


GGSCI (dgrac) 3> start reps1

Sending START request to MANAGER ...
REPLICAT REPS1 starting


GGSCI (dgrac) 4> info reps1

REPLICAT   REPS1     Last Started 2013-11-24 00:15   Status RUNNING
Checkpoint Lag       00:00:00 (updated 00:00:05 ago)
Log Read Checkpoint  File /u01/app/ogg/dirdat/s1000001
                     First Record  RBA 6310


GGSCI (dgrac) 5> exit

源端
-- 插入資料

07:04:54 LRJ@wailon> insert into s1(empno,ename) values(2000,'yojan');

1 row created.

07:05:15 LRJ@wailon> commit;

Commit complete.

07:05:17 LRJ@wailon> select * from s1;

     EMPNO ENAME      JOB              MGR HIREDATE            SAL       COMM     DEPTNO
---------- ---------- --------- ---------- ------------ ---------- ---------- ----------
      7369 SMITH      CLERK           7902 17-DEC-80          1000        100         20
      7499 ALLEN      SALESMAN        7698 20-FEB-81          1800        400         30
      7521 WARD       SALESMAN        7698 22-FEB-81          1450        600         30
      7566 JONES      MANAGER         7839 02-APR-81          3175        100         20
      7654 MARTIN     SALESMAN        7698 28-SEP-81          1450       1500         30
      7698 BLAKE      MANAGER         7839 01-MAY-81          3050        100         30
      7782 CLARK      MANAGER         7839 09-JUN-81          2650        100         10
      7788 SCOTT      ANALYST         7566 19-APR-87          3200        100         20
      7839 KING       PRESIDENT            17-NOV-81          5200        100         10
      7844 TURNER     SALESMAN        7698 08-SEP-81          1700        100         30
      7876 ADAMS      CLERK           7788 23-MAY-87          1300        100         20
      7900 JAMES      CLERK           7698 03-DEC-81          1150        100         30
      7902 FORD       ANALYST         7566 03-DEC-81          3200        100         20
      7934 MILLER     CLERK           7782 23-JAN-82          1500        100         10
      2000 yojan

15 rows selected.

目標端
-- 驗證資料

07:35:03 LRJ@ogg> select * from s1;

     EMPNO USERNAME   JOB              MGR HIREDATE            SAL       COMM     DEPTNO
---------- ---------- --------- ---------- ------------ ---------- ---------- ----------
      7369 SMITH      CLERK           7902 17-DEC-80          1000        100         20
      7499 ALLEN      SALESMAN        7698 20-FEB-81          1800        400         30
      7521 WARD       SALESMAN        7698 22-FEB-81          1450        600         30
      7566 JONES      MANAGER         7839 02-APR-81          3175        100         20
      7654 MARTIN     SALESMAN        7698 28-SEP-81          1450       1500         30
      7698 BLAKE      MANAGER         7839 01-MAY-81          3050        100         30
      7782 CLARK      MANAGER         7839 09-JUN-81          2650        100         10
      7788 SCOTT      ANALYST         7566 19-APR-87          3200        100         20
      7839 KING       PRESIDENT            17-NOV-81          5200        100         10
      7844 TURNER     SALESMAN        7698 08-SEP-81          1700        100         30
      7876 ADAMS      CLERK           7788 23-MAY-87          1300        100         20
      7900 JAMES      CLERK           7698 03-DEC-81          1150        100         30
      7902 FORD       ANALYST         7566 03-DEC-81          3200        100         20
      7934 MILLER     CLERK           7782 23-JAN-82          1500        100         10
      2000 yojan

15 rows selected.

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/429786/viewspace-1062216/,如需轉載,請註明出處,否則將追究法律責任。

相關文章