SELECT DISTINCT CLOB_COLUMN FROM TABLE;

后端 未结 7 845
情书的邮戳
情书的邮戳 2021-01-08 00:08

I would like to find the distinct CLOB values that can assume the column called CLOB_COLUMN (of type CLOB) contained in the table called COPIA.

I have selected a PRO

7条回答
  •  情话喂你
    2021-01-08 00:15

    If truncating the clob to the size of a varchar2 won't work, and you're worried about hash collisions, you can:

    • Add a row number to every row;
    • Use DBMS_lob.compare in a not exists subquery. Exclude duplicates (this means: compare = 0) with a higher rownum.

    For example:

    create table t (
      c1 clob
    );
    
    insert into t values ( 'xxx' );
    insert into t values ( 'xxx' );
    insert into t values ( 'yyy' );
    
    commit;
    
    with rws as (
       select row_number () over ( order by rowid ) rn,
              t.*
       from   t
    )
      select c1 from rws r1
      where  not exists (
        select * from rws r2
        where  dbms_lob.compare ( r1.c1, r2.c1 ) = 0
        and    r1.rn > r2.rn
      );
    
    C1    
    xxx   
    yyy  
    

提交回复
热议问题