博客
关于我
Postgresql 日期和时间类型
阅读量:387 次
发布时间:2019-03-05

本文共 1693 字,大约阅读时间需要 5 分钟。

PostgreSQL???????????????????

?PostgreSQL?????????????????????????????????????????????????????????

???????

PostgreSQL ??????????????????????????????????????????????????????????????????????????????????????????????

1. ??????????

???????????????????

  • CURRENT_DATE???????????????
  • CURRENT_TIME???????????????
  • CURRENT_TIMESTAMP???????????
  • CURRENT_TIME(precision)?????????????
  • LOCALTIME?????????????????
  • LOCALTIMESTAMP?????????????????????????

???????????????????????????????????

2. ??????????

???????????????????

  • now()????????????????????
  • timeofday()???????????????????
  • statement_timestamp()????????????????

??????????????????????????????????????

???????

??????????????????

highgo=# begin;BEGINhighgo=# select now(); now------------2023-10-18 14:22:45.678901+08:00 (1 row)highgo=# select statement_timestamp();statement_timestamp------------2023-10-18 14:22:47.890123+08:00 (1 row)

??????????? now() ? statement_timestamp() ???????????now() ????????????????? statement_timestamp() ????????????????

????????

????????????PostgreSQL ?????????????????????????

highgo=# create table t(date date);CREATE TABLEhighgo=# insert into t values (date '2023-10-18');INSERT 0 1

?????????????????????????

highgo=# insert into t values (timestamp '2023-10-18 14:22:45.678901+08:00');INSERT 0 1

???????PostgreSQL???????? ISO, MDY?????????????????????

highgo=# set datestyle = 'YMD';

???????

????????????????????????

highgo=# select time '12:09:00.123456';time---------12:09:00.123456 (1 row)

???????MySQL ????????? PostgreSQL ????????

??

? PostgreSQL ???????????????????????????????????????????????????????? CURRENT_TIMESTAMP ? LOCALTIMESTAMP?????????????????? now() ? timeofday()?

???????????????????????????????????

转载地址:http://qcowz.baihongyu.com/

你可能感兴趣的文章
Outlook 2010 Inside Out
查看>>
Outlook Express could not be started
查看>>
overlay(VLAN,VxLAN)、underlay网络、大二层概述
查看>>
OWASP漏洞原理<最基础的数据库 第二课>
查看>>
OWL本体语言
查看>>
P with Spacy:自定义文本分类管道
查看>>
P-DQN:离散-连续混合动作空间的独特算法
查看>>
P1035 I need help
查看>>
P1073 最优贸易
查看>>
P1207 双重回文数
查看>>
p1229
查看>>
P1273 有线电视网(树形dp)
查看>>
spring编程常见错误二 (学习笔记)
查看>>
P1364 医院设置
查看>>
P1614 爱与愁的心痛
查看>>
spring缓存注解@Cacheable、@CacheEvict、@CachePut使用
查看>>
P1865 A % B Problem
查看>>
P2158 [SDOI2008]仪仗队
查看>>
P2260 [清华集训2012]模积和
查看>>
P3203 [HNOI2010]弹飞绵羊 —— 懒标记?分块?
查看>>