Greenplum常用函数
字符串函数
函数 | 返回类型 | 描述 | 例子 | 结果 |
---|---|---|---|---|
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 |
字符串拼接示例: