[ 知识点 ] Greenplum常用函数

本文介绍了Greenplum中的一些常用函数,包括字符串函数、时间函数、数值计算函数和其他常用函数。例如,字符串拼接、分割,时间加减,序列号生成函数generate_series,以及hash函数md5和hashbpchar等。
摘要由CSDN通过智能技术生成

字符串函数

函数 返回类型 描述 例子 结果
string || string text 字符串连接 ‘Post’ || ‘greSQL’ PostgreSQL
length(string) int string 中字符串的数目 length(‘jose’) 4
position(substring in string) int 指定的子字符串的位置 position(‘om’ in ‘Thomas’) 3
substring(string [from int] [for int]) text 抽取子字符串 substring(‘Thomas’ from 2 for 3) hom
trim([leading | tailing | both] [characters] from string) text 从字符串string的开头 / 结尾 / 两边删除只包含characters中字符串(默认是一个空白)的最长的字符串 trim(both ‘x’ from ‘xTomxx’) Tom
lower(string) text 把字符串转为小写 lower(‘TOM’) tom
upper(string) text 把字符串转为大写 upper(‘tom’) TOM
overlay(string placing string from int [for int]) text 替换子字符串 overlay(‘Txxxxas’ placing ‘hom’ from 2 for 4) Thomas
replace(string text,from text , to text) text 把字符串string中出现的所有子字符串from替换成子字符串to replace(‘abcdefabcdef’,‘cd’,‘XX’) abXXefabXXef
split_part(string text,delimiter text,field int) text 根据delimiter分割string返回生成的第field个子字符串(1为基) split_part(‘abc|def|ghi’,’|’,2) def

字符串拼接示例:

  • select ‘green’ || ‘plum’ as dbname;
    ————
    grennplum

以 | 为分隔符,将字符串分割:

  • 3
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值