PostgreSQL学习篇9.9 日期时间类型

PostgreSQL学习篇9.9 日期时间类型,第1张

概述时间/日期类型:timestamp[(p)] [without time zone]timestamp[(p)] with time zone:日期和时间,带时区interval [(p)] :时间间隔date:只用于日期time[(p)] [without time zone] :只用于一日内时间time[(p)] with time zone :只用于一日内时间,带时区日期输入
时间/日期类型:timestamp[(p)] [without time zone]timestamp[(p)] with time zone:日期和时间,带时区interval [(p)] :时间间隔date:只用于日期time[(p)] [without time zone] :只用于一日内时间time[(p)] with time zone :只用于一日内时间,带时区日期输入:postgres=# show datastyle;ERROR:  unrecognized configuration parameter "datastyle"postgres=# show datestyle; DateStyle----------- ISO,MDY(1 row)postgres=# create table testd(col1 date);CREATE tablepostgres=# insert into testd values(date '12-23-16');INSERT 0 1postgres=# select * from testd;    col1   ------------ 2016-12-23(1 row)如果有日期列,注意datestyle的设置,因为同一个insert,不同的datestyle会有不同的意义:postgres=# show datestyle; DateStyle----------- ISO,MDY(1 row)postgres=# insert into testd values(date '1-2-2016');INSERT 0 1postgres=# set datestyle='DMY';SETpostgres=# insert into testd values(date '1-2-2016');INSERT 0 1postgres=# select * from testd;    col1   ------------ 2016-12-23 2016-01-02 2016-02-01(3 rows)postgres=#postgres=# select time '103245';   time   ---------- 10:32:45(1 row)各个时区缩写所表示意义:postgres=# select * from pg_timezone_abbrevs ;特殊时间:Now :当前事务的开始时间--可以类比Oracle中的sysdatepostgres=# select date 'Now';    date   ------------ 2016-12-06(1 row)postgres=# select timestamp 'Now';         timestamp         ---------------------------- 2016-12-06 04:17:01.645177(1 row)postgres=# select current_time;       timetz       -------------------- 05:01:51.535537+08(1 row)postgres=# select current_date;    date   ------------ 2016-12-06(1 row)postgres=# select current_timestamp;              Now             ------------------------------- 2016-12-06 05:02:08.058959+08(1 row) 
总结

以上是内存溢出为你收集整理的PostgreSQL学习篇9.9 日期/时间类型全部内容,希望文章能够帮你解决PostgreSQL学习篇9.9 日期/时间类型所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/1173577.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-02
下一篇 2022-06-02

发表评论

登录后才能评论

评论列表(0条)

保存