我个人up一下
是不是可以用minus来实现?可是我的数据表中可能有大对象的数据,minus好像不能用于大对象的。再次请高手指点,分不是问题,搞定再加100分。

解决方案 »

  1.   

    不知道是什么样的校验呢?
    只要可以在select statement中出现的,就可以用minus
      

  2.   

    我想要的校验就是针对每条记录进行比较,看是否完全一样,也就是看复制过来的数据是否正确。统计记录数是一方面,然后每条记录是否正确也要考虑。我最开始是想在两个表中正对每一条记录做字段长度(用lengthb)的求和,然后根据主键比较,可是这个方法我觉得比较麻烦,效率也不高。请再次指教!
    谢谢
      

  3.   

    有个牛人说DBMS_RECTIFIER_DIFF包可以实现包中有一个DIFFERENCES 方法
    This procedure determines the differences between two tables哪位用过这个package的,指点下。
      

  4.   

    select * from a minus select * from b;
    -------------------------------------------------
    用 minus 关键字,查找 a 表中与 b 表中的不同记录.
      

  5.   

    DBMS_RECTIFIER_DIFF:
    http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96612/d_recdi2.htm#93834Note: 
    This procedure cannot be used on LOB columns, nor on columns based on user-defined types.所以你说的牛人解决不了.
    create table a (id varchar2(10),name varchar2(20),photo clob)
    insert into a values(...);
    create table b (id varchar2(10),name varchar2(20),photo clob)
    insert into b values(...);create procedure pro
    as
    begin
    select count(1) into num from (select id,name,dbms_lob.substr(photo) photo from a
                            minus
                            select id,name,dbms_lob.substr(photo) from b);
    if num>0 then
    ....
    end if;
    end;
    /
      

  6.   

    谢谢beckham的注意,我试试先!
      

  7.   

    把表删除了,再建立CREATE TABLE AAA AS SELECT * FROM AAA1;
    这样肯定不会错,不过不是提倡的方法
      

  8.   


    beckham:
    select dbms_lob.substr(image) from table where rownum < 2The following error has occurred:ORA-06502: PL/SQL: 数字或值错误 :  原始变量长度太大
    ORA-06512: 在line 1
    怎么说dbms_lob.substr不行?
      

  9.   

    复制时采用事务机制,应该不会有数据不一致的情况出现。至于校验,统计记录数、对每一条记录做字段长度(用lengthb)的求和,也都不能100%确定一致,绝对的一致,就是逐个记录逐个字段值的比较。