云数据库 GAUSSDB-HashFunc函数:ora_hash(expression,[seed])
ora_hash(expression,[seed])
描述:用于计算给定表达式的哈希值。expression:可输入的类型覆盖字符串,时间类型,数字类型,根据expression进行计算哈希值。seed:可选参数,一个int8值,可以对同一个输入值返回不同的结果, 用于计算带随机数的hash值。
返回类型:int8类型的哈希值。
示例:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
gaussdb=# SELECT ora_hash(123); ora_hash ------------ 4089882933 (1 row) gaussdb=# SELECT ora_hash('123'); ora_hash ------------ 2034089965 (1 row) gaussdb=# SELECT ora_hash('sample'); ora_hash ------------ 1573005290 (1 row) gaussdb=# SELECT ora_hash(to_date('2012-1-2','yyyy-mm-dd')); ora_hash ------------ 1171473495 (1 row) gaussdb=# SELECT ora_hash(123,234); ora_hash ------------ -9089505052966355682 (1 row) gaussdb=# SELECT ora_hash('123',234); ora_hash ------------ 5742589019960764616 (1 row) gaussdb=# SELECT ora_hash('sample',234); ora_hash ------------ -1747984408055821656 (1 row) gaussdb=# SELECT ora_hash(to_date('2012-1-2','yyyy-mm-dd'),234); ora_hash ------------ -3306025179710572679 (1 row) |

此函数在参数a_format_version值为10c和a_format_dev_version值为s2的情况下才能生效。