【PostgreSQL】PostgreSQL语法

时间:2015-03-13 14:23:39   收藏:0   阅读:240

在阅读的过程中有任何问题,欢迎一起交流

邮箱:1494713801@qq.com   

QQ:1494713801

 

一、PostgreSQL时间类型转换

--时间类型转成字符类型
select to_char(current_date, ‘YYYY/MM/DD‘);
select to_char(current_date,‘YYYY-MM-DD‘);
select to_char(now(),‘YYYY-MM-DD‘);
select to_char(current_timestamp, ‘HH:MI:SS‘);
select to_char(current_timestamp, ‘YYYY/MM/DD HH:MI:SS‘);

--字符串类型转成时间类型
select to_date(‘2012/05/22‘,‘YYYY/MM/DD‘);
select to_date(‘2012-05-22‘,‘YYYY-MM-DD‘);
select to_timestamp(‘05 Sep 2010‘,‘DD mon YYYY‘);
select to_timestamp(‘2012/05/22‘,‘YYYY/MM/DD‘);
select to_timestamp(‘2012/05/22 02:55:46‘, ‘YYYY/MM/DD HH:MI:SS‘);
select to_timestamp(‘2012/05/22 02:55:46‘, ‘YYYY/MM/DD HH:MI:SS MS‘);

 

二、PostgreSQL-特有的类型转换操作符

::是类型转换操作符

如:avg(accesscount)::int4——将avg(accesscount)的值转换为int4

原文:http://blog.csdn.net/u010515761/article/details/44240237

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!