PostgreSQL学习篇9.9 日期/时间类型
来源:互联网 发布:数据分析师是青春饭吗 编辑:程序博客网 时间:2024/06/07 09:58
时间/日期类型: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)
0 0
- PostgreSQL学习篇9.9 日期/时间类型
- Postgresql 日期和时间类型
- Python:日期和时间类型学习
- postgreSQL字符串类型时间处理
- PostgreSQL学习篇9.1 布尔类型
- PostgreSQL学习篇9.2 数值类型
- PostgreSQL学习篇9.3 浮点数类型
- PostgreSQL学习篇9.4 序列类型
- PostgreSQL学习篇9.5 货币类型
- PostgreSQL学习篇9.7 字符串类型
- PostgreSQL学习篇9.8 位串类型
- PostgreSQL学习篇9.10 枚举类型
- PostgreSQL学习篇9.11 几何类型
- PostgreSQL学习篇9.12 网络地址类型
- PostgreSQL学习篇9.13 复合类型
- PostgreSQL学习篇9.14 XML类型
- PostgreSQL学习篇9.15 JSON类型
- PostgreSQL学习篇9.16 range类型
- 一步步学java框架之Spring-SpringMVC-Hibernate在idea的使用(三)
- MyBatis-级联
- HTML5 移动端 手机网站 开发流程
- JAVA中对存储过程的调用方法(引)
- 分享一个程序猿在开发流程表单中关于数据项有导出没导入功能的解决办法
- PostgreSQL学习篇9.9 日期/时间类型
- C++动态堆栈
- MVP架构
- 撒旦法撒嘎嘎
- js设置cookie和localStorage
- ionic利用gulp混淆代码与编译热更新
- 判断当前服务是否运行
- Solr进阶之Solr综合文本相似度的多因素权重排序实现
- Error: java.io.IOException: Can't export data, please check failed map task logs