SELECT DISTINCT CLOB_COLUMN FROM TABLE;

后端 未结 7 898
情书的邮戳
情书的邮戳 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:24

    You could compare the hashes of the CLOB to determine if they are different:

    SELECT your_clob
      FROM your_table
     WHERE ROWID IN (SELECT MIN(ROWID) 
                       FROM your_table
                      GROUP BY dbms_crypto.HASH(your_clob, dbms_crypto.HASH_SH1))
    

    Edit:

    The HASH function doesn't guarantee that there will be no collision. By design however, it is really unlikely that you will get any collision. Still, if the collision risk (<2^80?) is not acceptable, you could improve the query by comparing (with dbms_lob.compare) the subset of rows that have the same hashes.

提交回复
热议问题