云服务器内容精选

  • 自定义脱敏函数 支持用户使用PL/PGSQL语言自定义脱敏函数。 自定义脱敏函数需要严格遵循如下要求: 返回值与脱敏列类型一致。 函数必须可下推。 参数列表除脱敏格式外,只能包含一个脱敏列。 函数仅实现针对特定数据类型的格式化改写功能,不能涉及与其他表对象的复杂关联操作。 不满足前两项中任一项时,创建脱敏策略会报错。不满足后两项中任一项时,可成功创建脱敏策略,但查询执行结果可能会出现不可预知的问题。
  • mask_partial(column_name, mask_digital, mask_from[, mask_to]) 描述:针对数值类型数据,将第mask_from到mask_to位的数字部分脱敏成mask_digital对应的数字。其中,参数mask_to允许缺省,缺省时即脱敏到数据结束位置。参数mask_digital只能取[0,9]区间内的数字。 返回值类型:与入参column_name数据类型相同。
  • mask_partial(column_name [, input_format, output_format], mask_char, mask_from[, mask_to]) 描述:针对字符类型数据,对照指定的输入输出格式,将第mask_from到mask_to位的数字部分脱敏成mask_char指定的字符。 参数说明: input_format 输入格式是由V和F组成的字符序列,与脱敏列数据长度相同。V对应位置的字符可能会被脱敏,F对象位置的字符会被忽略跳过,V字符序列标识脱敏范围。输入输出格式参数适用于定长数据,比如,银行卡号、身份证号、手机号等。 output_format 输出格式是由V和其他任意字符组成的字符序列,与脱敏列数据长度相同。V字符位置与input_format的V位置对应,其他字符位置与input_format的F位置对应,且不会脱敏,通常为数据分隔符。 input_format和output_format可以缺省或指定为空串"",此时,无输入输出格式要求,原始字符序列范围即为脱敏范围。 mask_char 脱敏字符,仅允许长度为1的任意字符。场景的脱敏字符包括"*","#"等。 mask_from 脱敏范围的起始位置,要求大于0。 mask_to 脱敏范围的结束位置,允许缺省。缺省时,即脱敏到原始数据结束位置。 返回值类型:与入参column_name数据类型相同。
  • mask_partial(column_name, mask_field1, mask_value1, mask_field2, mask_value2, mask_field3, mask_value3) 描述:按指定三个时间域做部分脱敏,仅适用于日期或时间类型数据。若mask_value取-1,即此mask_field不脱敏。其中,mask_field可以取"month"、"day"、"year"、"hour"、"minute"、"second"六个时间域之一。各域的取值范围需满足实际时间单位的取值范围。 返回值类型:与入参column_name数据类型相同。
  • hotkey特性函数 gs_stat_get_hotkeys_info() 描述:获取本地节点查询的热词信息。 返回值类型:Tuple 示例: 1 2 3 4 5 6 gaussdb=# select * from gs_stat_get_hotkeys_info() order by count, hash_value; database_name | schema_name | table_name | key_value | hash_value | count ---------------+-------------+-------------------+-----------+------------+------- regression | public | hotkey_single_col | {22} | 1858004829 | 2 regression | public | hotkey_single_col | {11} | 2011968649 | 2 (2 rows) gs_stat_clean_hotkeys() 描述:清理hotkey缓存,重置hotkey状态信息。 返回值类型:bool,恒为true 示例: 1 2 3 4 5 gaussdb=# select * from gs_stat_clean_hotkeys(); gs_stat_clean_hotkeys ----------------------- t (1 row) 父主题: 函数和操作符
  • 废弃函数 由于版本升级,HLL(HyperLogLog)有一些旧的函数废弃,用户可以用类似的函数进行替代。 hll_schema_version(hll) 描述:查看当前hll中的schema version。旧版本schema version是常值1,用来进行hll字段的头部校验,重构后的hll在头部增加字段“HLL”进行校验,schema version不再使用。 hll_regwidth(hll) 描述:查看hll数据结构中桶的位数大小。旧版本桶的位数regwidth取值1~5,会存在较大的误差,也限制了基数估计上限。 重构后regwidth为固定值6,不再使用regwidth变量。 hll_expthresh(hll) 描述:得到当前hll中expthresh大小。采用hll_log2explicit(hll)替代类似功能。 hll_sparseon(hll) 描述:是否启用Sparse模式。采用hll_log2sparse(hll)替代类似功能,0表示关闭Sparse模式。
  • 聚合函数 hll_add_agg(hll_hashval) 描述:把哈希后的数据按照分组放到hll中。 返回值类型:hll 示例: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 --准备数据 gaussdb=# CREATE TABLE t_id(id int); gaussdb=# INSERT INTO t_id VALUES(generate_series(1,500)); gaussdb=# CREATE TABLE t_data(a int, c text); gaussdb=# INSERT INTO t_data SELECT mod(id,2), id FROM t_id; --创建表并指定列为hll gaussdb=# CREATE TABLE t_a_c_hll(a int, c hll); --根据a列GROUP BY对数据分组,把各组数据加到hll中 gaussdb=# INSERT INTO t_a_c_hll SELECT a, hll_add_agg(hll_hash_text(c)) FROM t_data GROUP BY a; --得到每组数据中hll的Distinct值 gaussdb=# SELECT a, #c AS cardinality FROM t_a_c_hll ORDER BY a; a | cardinality ---+------------------ 0 | 247.862354346299 1 | 250.908710610377 (2 rows)
  • 操作符 = 描述:比较hll或hll_hashval的值是否相等。 返回值类型:bool 示例: 1 2 3 4 5 6 7 8 9 10 11 12 13 --hll gaussdb=# SELECT (hll_empty() || hll_hash_integer(1)) = (hll_empty() || hll_hash_integer(1)); column ---------- t (1 row) --hll_hashval gaussdb=# SELECT hll_hash_integer(1) = hll_hash_integer(1); ?column? ---------- t (1 row)
  • 日志函数 hll主要存在三种模式Explicit、Sparse、Full。当数据规模比较小的时候会使用Explicit模式,这种模式下distinct值的计算是没有误差的;随着distinct值越来越多,hll会先后转换为Sparse模式和Full模式,这两种模式在计算结果上没有任何区别,只影响hll函数的计算效率和hll对象的存储空间。下面的函数可以用于查看hll的一些参数。 hll_print(hll) 描述:打印hll的一些debug参数信息。 示例: 1 2 3 4 5 gaussdb=# SELECT hll_print(hll_empty()); hll_print ------------------------------------------------------------------------------- type=1(HLL_EMPTY), log2m=14, log2explicit=10, log2sparse=12, duplicatecheck=0 (1 row)
  • 功能函数 hll_empty() 描述:创建一个空的hll。 返回值类型:hll 示例: 1 2 3 4 5 gaussdb=# SELECT hll_empty(); hll_empty ------------------------------------------------------------ \x484c4c00000000002b05000000000000000000000000000000000000 (1 row) hll_empty(int32 log2m) 描述:创建空的hll并指定参数log2m,取值范围是10到16。若输入-1,则采用内置默认值。 返回值类型:hll 示例: 1 2 3 4 5 6 7 8 9 10 11 gaussdb=# SELECT hll_empty(10); hll_empty ------------------------------------------------------------ \x484c4c00000000002b04000000000000000000000000000000000000 (1 row) gaussdb=# SELECT hll_empty(-1); hll_empty ------------------------------------------------------------ \x484c4c00000000002b05000000000000000000000000000000000000 (1 row) hll_empty(int32 log2m, int32 log2explicit) 描述:创建空的hll并依次指定参数log2m、log2explicit。log2explicit取值范围是0到12,0表示直接跳过Explicit模式。该参数可以用来设置Explicit模式的阈值大小,在数据段长度达到2log2explicit后切换为Sparse模式或者Full模式。若输入-1,则log2explicit采用内置默认值。 返回值类型: hll 示例: 1 2 3 4 5 6 7 8 9 10 11 gaussdb=# SELECT hll_empty(10, 4); hll_empty ------------------------------------------------------------ \x484c4c00000000001304000000000000000000000000000000000000 (1 row) gaussdb=# SELECT hll_empty(10, -1); hll_empty ------------------------------------------------------------ \x484c4c00000000002b04000000000000000000000000000000000000 (1 row) hll_empty(int32 log2m, int32 log2explicit, int64 log2sparse) 描述:创建空的hll并依次指定参数log2m、log2explicit、log2sparse。log2sparse取值范围是0到14,0表示直接跳过Sparse模式。该参数可以用来设置Sparse模式的阈值大小,在数据段长度达到2log2sparse后切换为Full模式。若输入-1,则log2sparse采用内置默认值。 返回值类型:hll 示例: 1 2 3 4 5 6 7 8 9 10 11 gaussdb=# SELECT hll_empty(10, 4, 8); hll_empty ------------------------------------------------------------ \x484c4c00000000001204000000000000000000000000000000000000 (1 row) gaussdb=# SELECT hll_empty(10, 4, -1); hll_empty ------------------------------------------------------------ \x484c4c00000000001304000000000000000000000000000000000000 (1 row) hll_empty(int32 log2m, int32 log2explicit, int64 log2sparse, int32 duplicatecheck) 描述:创建空的hll并依次指定参数log2m、log2explicit、log2sparse、duplicatecheck。duplicatecheck取0或者1,表示是否开启该模式,默认情况下该模式会关闭。若输入-1,则duplicatecheck采用内置默认值。 返回值类型:hll 示例: 1 2 3 4 5 6 7 8 9 10 11 gaussdb=# SELECT hll_empty(10, 4, 8, 0); hll_empty ------------------------------------------------------------ \x484c4c00000000001204000000000000000000000000000000000000 (1 row) gaussdb=# SELECT hll_empty(10, 4, 8, -1); hll_empty ------------------------------------------------------------ \x484c4c00000000001204000000000000000000000000000000000000 (1 row) hll_add(hll, hll_hashval) 描述:把hll_hashval加入到hll中。 返回值类型:hll 示例: 1 2 3 4 5 gaussdb=# SELECT hll_add(hll_empty(), hll_hash_integer(1)); hll_add ---------------------------------------------------------------------------- \x484c4c08000002002b0900000000000000f03f3e2921ff133fbaed3e2921ff133fbaed00 (1 row) hll_add_rev(hll_hashval, hll) 描述:把hll_hashval加入到hll中,和hll_add功能一样,只是参数位置进行了交换。 返回值类型:hll 示例: 1 2 3 4 5 gaussdb=# SELECT hll_add_rev(hll_hash_integer(1), hll_empty()); hll_add_rev ---------------------------------------------------------------------------- \x484c4c08000002002b0900000000000000f03f3e2921ff133fbaed3e2921ff133fbaed00 (1 row) hll_eq(hll, hll) 描述:比较两个hll是否相等。 返回值类型:bool 示例: 1 2 3 4 5 gaussdb=# SELECT hll_eq(hll_add(hll_empty(), hll_hash_integer(1)), hll_add(hll_empty(), hll_hash_integer(2))); hll_eq -------- f (1 row) hll_ne(hll, hll) 描述:比较两个hll是否不相等。 返回值类型:bool 示例: 1 2 3 4 5 gaussdb=# SELECT hll_ne(hll_add(hll_empty(), hll_hash_integer(1)), hll_add(hll_empty(), hll_hash_integer(2))); hll_ne -------- t (1 row) hll_cardinality(hll) 描述:计算hll的distinct值。 返回值类型:int 示例: 1 2 3 4 5 gaussdb=# SELECT hll_cardinality(hll_empty() || hll_hash_integer(1)); hll_cardinality ----------------- 1 (1 row) hll_union(hll, hll) 描述:把两个hll数据结构union成一个。 返回值类型:hll 示例: 1 2 3 4 5 gaussdb=# SELECT hll_union(hll_add(hll_empty(), hll_hash_integer(1)), hll_add(hll_empty(), hll_hash_integer(2))); hll_union -------------------------------------------------------------------------------------------- \x484c4c10002000002b090000000000000000400000000000000000b3ccc49320cca1ae3e2921ff133fbaed00 (1 row)
  • 废弃函数 GaussDB 中下列函数在最新版本中已废弃: gs_wlm_get_session_info gs_wlm_get_user_session_info check_engine_status encode_plan_node model_train_opt gs_stat_get_wlm_plan_operator_info track_model_train_opt array_extend dbe_perf.global_slow_query_info dbe_perf.global_slow_query_info_bytime dbe_perf.global_slow_query_history pg_reload_conf pg_rotate_logfile gs_stat_ustore pv_compute_pool_workload() pgxc_log_comm_status(void) 父主题: 函数和操作符
  • 数组函数 array_append(anyarray, anyelement) 描述:向数组末尾添加元素,只支持一维数组。 返回类型:anyarray 示例: 1 2 3 4 5 gaussdb=# SELECT array_append(ARRAY[1,2], 3) AS RESULT; result --------- {1,2,3} (1 row) array_prepend(anyelement, anyarray) 描述:向数组开头添加元素,只支持一维数组。 返回类型:anyarray 示例: 1 2 3 4 5 gaussdb=# SELECT array_prepend(1, ARRAY[2,3]) AS RESULT; result --------- {1,2,3} (1 row) array_cat(anyarray, anyarray) 描述:连接两个数组,支持多维数组。 返回类型:anyarray 示例: 1 2 3 4 5 6 7 8 9 10 11 gaussdb=# SELECT array_cat(ARRAY[1,2,3], ARRAY[4,5]) AS RESULT; result ------------- {1,2,3,4,5} (1 row) gaussdb=# SELECT array_cat(ARRAY[[1,2],[4,5]], ARRAY[6,7]) AS RESULT; result --------------------- {{1,2},{4,5},{6,7}} (1 row) array_union(anyarray, anyarray) 描述:连接两个数组,只支持一维数组。有入参为NULL时返回另一个入参。 返回类型:anyarray 示例: 1 2 3 4 5 6 7 8 9 10 11 gaussdb=# SELECT array_union(ARRAY[1,2,3], ARRAY[3,4,5]) AS RESULT; result ------------- {1,2,3,3,4,5} (1 row) gaussdb=# SELECT array_union(ARRAY[1,2,3], NULL) AS RESULT; result --------- {1,2,3} (1 row) array_union_distinct(anyarray, anyarray) 描述:连接两个数组,并去重,只支持一维数组。有入参为NULL时返回另一个入参。 返回类型:anyarray 示例: 1 2 3 4 5 6 7 8 9 10 11 gaussdb=# SELECT array_union_distinct(ARRAY[1,2,3], ARRAY[3,4,5]) AS RESULT; result ------------- {1,2,3,4,5} (1 row) gaussdb=# SELECT array_union_distinct(ARRAY[1,2,3], NULL) AS RESULT; result --------- {1,2,3} (1 row) array_intersect(anyarray, anyarray) 描述:两个数组取交集,只支持一维数组。有入参为NULL时返回NULL。 返回类型:anyarray 示例: 1 2 3 4 5 6 7 8 9 10 11 gaussdb=# SELECT array_intersect(ARRAY[1,2,3], ARRAY[3,4,5]) AS RESULT; result ------------- {3} (1 row) gaussdb=# SELECT array_intersect(ARRAY[1,2,3], NULL) AS RESULT; result -------- (1 row) array_intersect_distinct(anyarray, anyarray) 描述:两个数组取交集,并去重,只支持一维数组。有入参为NULL时返回NULL。 返回类型:anyarray 示例: 1 2 3 4 5 6 7 8 9 10 11 gaussdb=# SELECT array_intersect_distinct(ARRAY[1,2,2], ARRAY[2,2,4,5]) AS RESULT; result ------------- {2} (1 row) gaussdb=# SELECT array_intersect_distinct(ARRAY[1,2,3], NULL) AS RESULT; result -------- (1 row) array_except(anyarray, anyarray) 描述:两个数组取差,只支持一维数组。第一个入参为NULL时返回NULL,第二个入参为NULL时返回第一个入参。 返回类型:anyarray 示例: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 gaussdb=# SELECT array_except(ARRAY[1,2,3], ARRAY[3,4,5]) AS RESULT; result ------------- {1,2} (1 row) gaussdb=# SELECT array_except(ARRAY[1,2,3], NULL) AS RESULT; result --------- {1,2,3} (1 row) gaussdb=# SELECT array_except(NULL, ARRAY[3,4,5]) AS RESULT; result -------- (1 row) array_except_distinct(anyarray, anyarray) 描述:两个数组取差,并去重,只支持一维数组。第一个入参为NULL时返回NULL,第二个入参为NULL时返回第一个入参。 返回类型:anyarray 示例: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 gaussdb=# SELECT array_except_distinct(ARRAY[1,2,2,3], ARRAY[3,4,5]) AS RESULT; result ------------- {1,2} (1 row) gaussdb=# SELECT array_except_distinct(ARRAY[1,2,3], NULL) AS RESULT; result --------- {1,2,3} (1 row) gaussdb=# SELECT array_except_distinct(NULL, ARRAY[3,4,5]) AS RESULT; result -------- (1 row) array_ndims(anyarray) 描述:返回数组的维数。 返回类型:int 示例: 1 2 3 4 5 gaussdb=# SELECT array_ndims(ARRAY[[1,2,3], [4,5,6]]) AS RESULT; result -------- 2 (1 row) array_dims(anyarray) 描述:返回数组维数的文本表示。 返回类型:text 示例: 1 2 3 4 5 gaussdb=# SELECT array_dims(ARRAY[[1,2,3], [4,5,6]]) AS RESULT; result ------------ [1:2][1:3] (1 row) array_length(anyarray, int) 描述:返回数组维度的长度。 返回类型:int 示例: 1 2 3 4 5 gaussdb=# SELECT array_length(array[1,2,3], 1) AS RESULT; result -------- 3 (1 row) array_lower(anyarray, int) 描述:返回数组维数的下界。 返回类型:int 示例: 1 2 3 4 5 gaussdb=# SELECT array_lower('[0:2]={1,2,3}'::int[], 1) AS RESULT; result -------- 0 (1 row) array_sort(anyarray) 描述:返回从小到大排列好的数组。 返回类型:anyarray 示例: 1 2 3 4 5 gaussdb=# SELECT array_sort(ARRAY[5,1,3,6,2,7]) AS RESULT; result ------------- {1,2,3,5,6,7} (1 row) array_upper(anyarray, int) 描述:返回数组维数的上界。 返回类型:int 示例: 1 2 3 4 5 gaussdb=# SELECT array_upper(ARRAY[1,8,3,7], 1) AS RESULT; result -------- 4 (1 row) array_to_string(anyarray, text [, text]) 描述:使用第一个text作为数组的新分隔符,使用第二个text替换数组值为NULL的值。 返回类型:text 示例: 1 2 3 4 5 gaussdb=# SELECT array_to_string(ARRAY[1, 2, 3, NULL, 5], ',', '*') AS RESULT; result ----------- 1,2,3,*,5 (1 row) array_delete(anyarray) 描述:清空数组中的元素并返回一个同类型的空数组。 返回类型:anyarray 示例: gaussdb=# SELECT array_delete(ARRAY[1,8,3,7]) AS RESULT; result -------- {} (1 row) array_deleteidx(anyarray, int) 描述:从数组中删除指定下标的元素并返回剩余元素组成的数组。 返回类型:anyarray 示例: gaussdb=# SELECT array_deleteidx(ARRAY[1,2,3,4,5], 1) AS RESULT; result ----------- {2,3,4,5} (1 row) array_deleteidx(anyarray, int)此函数在ORA兼容模式数据库中且参数a_format_version值为10c和a_format_dev_version值为s1的情况下被禁用。 array_extendnull(anyarray, int) 描述:往数组尾部添加指定个数空元素。 返回类型:anyarray 示例: gaussdb=# SELECT array_extendnull(ARRAY[1,8,3,7],1) AS RESULT; result -------------- {1,8,3,7,null} (1 row) array_extendnull(anyarray, int, int) 描述:往数组尾部添加指定个数的指定索引的元素。 返回类型:anyarray 示例: gaussdb=# SELECT array_extendnull(ARRAY[1,8,3,7],2,2) AS RESULT; result -------------- {1,8,3,7,8,8} (1 row) array_extendnull(anyarray, int, int)此函数在ORA兼容模式数据库中且参数a_format_version值为10c和a_format_dev_version值为s1的情况下有效。 array_trim(anyarray, int) 描述:从数组尾部删除指定个数个元素。 返回类型:anyarray 示例: gaussdb=# SELECT array_trim(ARRAY[1,8,3,7],1) AS RESULT; result --------- {1,8,3} (1 row) array_exists(anyarray, int) 描述:检查第二个参数是否是数组的合法下标。 返回类型:boolean 示例: gaussdb=# SELECT array_exists(ARRAY[1,8,3,7],1) AS RESULT; result -------- t (1 row) array_next(anyarray, int) 描述:根据第二个入参返回数组中指定下标元素的下一个元素的下标。 返回类型:int 示例: gaussdb=# SELECT array_next(ARRAY[1,8,3,7],1) AS RESULT; result -------- 2 (1 row) array_prior(anyarray, int) 描述:根据第二个入参返回数组中指定下标元素的上一个元素的下标。 返回类型:int 示例: gaussdb=# SELECT array_prior(ARRAY[1,8,3,7],2) AS RESULT; result -------- 1 (1 row) string_to_array(text, text [, text]) 描述:使用第二个text指定分隔符,使用第三个可选的text作为NULL值替换模板,如果分隔后的子串与第三个可选的text完全匹配,则将其替换为NULL。 返回类型:text[] 示例: 1 2 3 4 5 6 7 8 9 10 gaussdb=# SELECT string_to_array('xx~^~yy~^~zz', '~^~', 'yy') AS RESULT; result -------------- {xx,NULL,zz} (1 row) gaussdb=# SELECT string_to_array('xx~^~yy~^~zz', '~^~', 'y') AS RESULT; result ------------ {xx,yy,zz} (1 row) unnest(anyarray) 描述:扩大一个数组为一组行。 返回类型:setof anyelement 示例: 1 2 3 4 5 6 gaussdb=# SELECT unnest(ARRAY[1,2]) AS RESULT; result -------- 1 2 (2 rows)
  • HashFunc函数 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的情况下才能生效。 hash_array(anyarray) 描述:数组哈希,将数组的元素通过哈希函数得到结果,并返回合并结果。 参数:数据类型为anyarray。 返回值类型:integer 示例: 1 2 3 4 5 gaussdb=# select hash_array(ARRAY[[1,2,3],[1,2,3]]); hash_array ------------ -382888479 (1 row) hash_numeric(numeric) 描述:计算Numeric类型的数据的hash值。 参数:Numeric类型的数据。 返回值类型:integer 示例: 1 2 3 4 5 gaussdb=# select hash_numeric(30); hash_numeric -------------- -282860963 (1 row) hash_range(anyrange) 描述:计算range的哈希值。 参数:anyrange类型的数据。 返回值类型:integer 示例: 1 2 3 4 5 gaussdb=# select hash_range(numrange(1.1,2.2)); hash_range ------------ 683508754 (1 row) hashbpchar(character) 描述:计算bpchar的哈希值。 参数:character类型的数据。 返回值类型:integer 示例: 1 2 3 4 5 gaussdb=# select hashbpchar('hello'); hashbpchar ------------- -1870292951 (1 row) hashchar(char) 描述:char和布尔数据转换为哈希值。 参数:char类型的数据或者bool类型的数据。 返回值类型:integer 示例: 1 2 3 4 5 6 7 8 9 10 11 gaussdb=# select hashbpchar('hello'); hashbpchar ------------- -1870292951 (1 row) gaussdb=# select hashchar('true'); hashchar ------------ 1686226652 (1 row) hashenum(anyenum) 描述:枚举类型转哈希值。 参数:anyenum类型的数据。 返回值类型:integer 示例: 1 2 3 4 5 6 7 gaussdb=# CREATE TYPE b1 AS ENUM('good', 'bad', 'ugly'); CREATE TYPE gaussdb=# call hashenum('good'::b1); hashenum ------------ 1821213359 (1 row) hashfloat4(real) 描述:float4转哈希值。 参数:real类型的数据。 返回值类型:integer 示例: 1 2 3 4 5 gaussdb=# select hashfloat4(12.1234); hashfloat4 ------------ 1398514061 (1 row) hashfloat8(double precision) 描述:float8转哈希值。 参数:double precision类型的数据。 返回值类型:integer 示例: 1 2 3 4 5 gaussdb=# select hashfloat8(123456.1234); hashfloat8 ------------ 1673665593 (1 row) hashinet(inet) 描述:inet / cidr转哈希值。 参数:inet类型的数据。 返回值类型:integer 示例: 1 2 3 4 5 gaussdb=# select hashinet('127.0.0.1'::inet); hashinet ------------- -1435793109 (1 row) hashint1(tinyint) 描述:INT1转哈希值。 参数:tinyint类型的数据。 返回值类型:uint32 示例: 1 2 3 4 5 gaussdb=# select hashint1(20); hashint1 ------------- -2014641093 (1 row) hashint2(smallint) 描述:INT2转哈希值。 参数:smallint类型的数据。 返回值类型:uint32 示例: gaussdb=# select hashint2(20000); hashint2 ------------ -863179081 (1 row) 父主题: 函数和操作符
  • 下标生成函数 generate_subscripts(array anyarray, dim int) 描述:生成一系列包括给定数组的下标。 返回值类型:setof int generate_subscripts(array anyarray, dim int, reverse boolean) 描述:生成一系列包括给定数组的下标。当reverse为真时,该系列则以相反的顺序返回。 返回值类型:setof int
  • 序列号生成函数 generate_series(start, stop) 描述:生成一个数值序列,从start到stop,步长为1。 参数类型:int、bigint、numeric 返回值类型:setof int、setof bigint、setof numeric(与参数类型相同) generate_series(start, stop, step) 描述:生成一个数值序列,从start到stop,步长为step。 参数类型:int、bigint、numeric 返回值类型:setof int、setof bigint、setof numeric(与参数类型相同) generate_series(start, stop, step interval) 描述:生成一个数值序列,从start到stop,步长为step。 参数类型:timestamp或timestamp with time zone 返回值类型:setof timestamp或setof timestamp with time zone(与参数类型相同)