ora_hash是确定性的吗? [英] Is ora_hash deterministic?

查看:149
本文介绍了ora_hash是确定性的吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Oracle数据库,因此需要能够对表中的数据进行分区.我了解Rracle具有ora_hash函数,该函数可以将数据分区到存储桶中.是否可以确定ora_hash函数?

I am working with an Oracle database and I need to be able to partition the data in a table. I understand that Rracle has an ora_hash function that can partition the data into buckets. Is the ora_hash function deterministic?

在我的程序中,我将进行几个不同的数据库查询,每个查询要求一个不同的存储桶编号.

In my program I will be making several different database queries with each query asking for a different bucket number.

例如,在一个查询中,我可能会要求输入前两个存储桶:

For example, in one query I might ask for the first two buckets:

SELECT * FROM sales WHERE ORA_HASH(cust_id, 9) in (0,1);

在随后的查询中,我可能会要求第二个和第三个存储桶:

In a subsequent query I might ask for the 2nd and 3rd bucket:

SELECT * FROM sales WHERE ORA_HASH(cust_id, 9) in (1,2);

在上面的示例中,ora_hash是否总是将表划分为完全相同的10个存储桶?假设表中的数据没有更改.第二个存储桶(存储桶1)在两个查询中是否相同?

In the above example, will ora_hash always divide the table into the exact same 10 buckets? Assume that the data in the tables hasn't changed. Will the second bucket (bucket 1), be identical in both queries?

有些文档建议 seed value 使oracle对同一数据集返回不同的结果.因此,我假设如果我不使用种子值,那么ora_hash将是确定性的.请参见文档.

There is documentation that suggests that seed value enables oracle to return different results for the same data set. So I am assuming that if I don't use seed value, then ora_hash will be deterministic. See the documentation.

推荐答案

乔恩·海勒(Jon Heller)的答案有更多详细信息,因此请投票支持他的答案.由于这仍然是公认的答案,因此我将内联他的部分答复:

Jon Heller's answer has some more details, so go upvote his answer. Since this is the accepted answer still, I'll inline part of his response:

ORA_HASH对于可以用于分区的数据类型(例如NUMBERVARCHARDATE等)绝对是确定的.

ORA_HASH is definitely deterministic for data types that can be used for partitioning, such as NUMBER, VARCHAR, DATE, etc.

但是对于至少某些其他数据类型(例如CLOB),ORA_HASH不确定.

But ORA_HASH is not deterministic for at least some of the other data types, such as CLOB.

这篇关于ora_hash是确定性的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆