加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

oracle – 如何在数据类型xmltype的列上使用ora_hash

发布时间:2020-12-12 13:50:05 所属栏目:百科 来源:网络整理
导读:我想在xmltype数据类型上使用ORA_HASH,解决方法是直接的解决方案吗? 我使用oracle 11g r2和二进制xml作为xmltype列的存储选项 我用于创建表的查询是 create table samplebinary(indexid number(19,0),xmlcolumn xmltype not null)xmltype column xmlcolumn
我想在xmltype数据类型上使用ORA_HASH,解决方法是直接的解决方案吗?

我使用oracle 11g r2和二进制xml作为xmltype列的存储选项

我用于创建表的查询是

create table samplebinary(indexid number(19,0),xmlcolumn xmltype not null)xmltype column xmlcolumn store as binary xml;

正如您所知,ora_hash doesn’t accept long or LOB values.您可以传入XML内容的前4k或32k,但如果您需要确保整个XML文档没有更改,那么这还不够.正如Ben提到的那样,ora_hash最多有4294967295个桶,因此碰撞比使用SHA-1或MD5更可能.正如文档所述,ora_hash’对于分析数据子集和生成随机样本等操作非常有用.

您可以使用the dbms_crypto package来散列整个XMLType值,作为使用the getClobVal function提取的CLOB,使用包装函数使其更易于使用:

create or replace function my_hash(xml xmltype) return raw is
begin
  return dbms_crypto.hash(src=>xml.getclobval(),typ=>dbms_crypto.hash_sh1);
end;
/

然后,您可以将XMLType作为值或列作为select的一部分传递:

select my_hash(xml) from t42;

MY_HASH(XML)                                 
---------------------------------------------
494C4E7688963BCF312B709B33CD1B5CCA7C0289

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读