postgresql之greenplum字符串去重拼接方式


    目录
  • postgresql greenplum字符串去重拼接
  • postgresql字符串处理方式
    • 关于查找字符串
    • 字符串与数字的相互转换
  • 总结

    postgresql greenplum字符串去重拼接
    pg 、gp 实现 collect_set  效果:
    
array_agg(DISTINCT $columnName))
array(SELECT DISTINCT ? $columnName ?from $tableName )

    字符串拼接 :
    
array_to_string(array_agg(DISTINCT ), '|')?

    postgresql字符串处理方式
    关于查找字符串
    
select position('hello' in 'test_sql')?
output:0
select position('test' in 'test_sql')?
output:1

    故可用position(str_1 in str_2) != 0判断str_1是否是str_2的子串。
    字符串与数字的相互转换
    字符串->数字
    to_number(block_id,'999999')和cast(block_id as numeric),但前一句会限定的数字大小为10的5次方,即过大的数值会出问题,而后一句不会。
    数字->字符串
    cast(block_id as varchar)将数值型转为字符串型。
    总结
    以上为个人经验,希望能给大家一个参考,也希望大家多多支持电脑手机教程网。