ITPub博客

首页 > 数据库 > > greenplum常用函数

greenplum常用函数

作者:TTT1234 时间:2023-03-01 17:12:14 0 删除 编辑
--【常用字符串函数】
--字符串连接
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();


本文来源https://blog.csdn.net/zqmy_/article/details/112889432

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/69953058/viewspace-3120584/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-11-13

  • 博文量
    566
  • 访问量
    5207