2010年9月27日

DML SQL with keyword SYSDATE may cause trouble in Oracle Stream Replication

Tow database, one way replication, if you execute DML SQL like "insert into tab (id, operate_time) values ('1',SYSDATA)" in source database. this exactly SQL will execute in destination database too, but it will execute on destination database short after the executing of source database.

(I think the period is not short sometimes, if some network problem occurs, or some other operation delay the executing on destination database.)

Yes, this SQL do not execute at same time on source database and the destination database. and the column operate_time will have different value in the two database.

OK, the value of column operate_time in two database have little different, it is not a big problem. I don't care!

Latter, I execute this SQL: "delete tab where 1=1" in source database. Oops, I got this ORA-26786 shit in destination database

1 条评论:

  1. Following procedure may solve this problem, execute it in the destination database. (replace "FRAME" with the schema name in you database)

    More detail here: http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_apply.htm#i1006610

    DECLARE
    CURSOR C1 IS select OWNER||'.'||TABLE_NAME AS t from dba_tables where owner='FRAME';
    BEGIN
    FOR I IN C1 LOOP
    sys.dbms_apply_adm.compare_old_values(i.t,'*','*', false,null);
    END LOOP;
    END;

    回复删除