天天看点

greenplum常用函数

--【常用字符串函数】
--字符串连接 
select 'green'||'plum';
--greenplum


--string中字符的数目 
select length('greenplum');
--9


--抽取子字符串
select substring('greenplum' from 6 for 4);
--plum


--删除字符两端空格
select trim('  greenplum ');
--greenplum


--删除字符串的指定字符
select trim(both 'x' from 'xgreenplumxx');
--greenplum


--按照分隔符分割字符串
select split_part('abc|def|ght','|',2);
--def


--【常用日期相关函数】
--获取当前的日期
select current_date;


--获取当前的时间戳
select now();
--select localtimestamp;
--select current_timestamp;


--获取时间戳的指定参数 year,month,day,hour,minute,second
select date_part('month',timestamp'2020-11-07 11:07:30');


--获取日期的指定部分
select to_char(now(),'yyyy');


--日期转字符串
select to_char(now(),'YYYY-MM-DD HH24:MI:SS');


--字符串转日期
select to_date('20110720','yyyymmdd')


--日期加减
select now() + interval '1 day' - interval '1 month';


--非空处理
select coalesce(null,'未知');


--另外,查看数据库版本信息     
select version();


           

继续阅读