PG(HGDB)时间函数

本文介绍了PostgreSQL(HighGo DB,简称PG)中获取当前时间与日期的多个函数,包括now()、current_timestamp、transaction_timestamp、localtime、localtimestamp、current_time、current_date、statement_timestamp、clock_timestamp和timeofday。这些函数在数据库操作中用于获取系统当前的时间和日期信息。
highgo=# select now();
              now              
-------------------------------
 2017-06-21 13:52:39.407304+08
(1 row)


highgo=# select current_timestamp;
              now              
-------------------------------
 2017-06-21 13:53:07.656107+08
(1 row)


highgo=# select transaction_timestamp();
     transaction_timestamp     
-------------------------------
 2017-06-21 13:53:24.948411+08
(1 row)




以上三个函数是等效的
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
highgo=# select localtime;
      time      
----------------
 13:53:36.46901
(1 row)


highgo=# select localtimestamp;
         timestamp          
----------------------------
 2017-06-21 13:53:39.921847
(1 row)


highgo=# select current_time;
       timetz       
--------------------
 13:53:56.716011+08
(1 row)


highgo=# select current_date;
    date    
------------
 2017-06-21
(1 row)


+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
以下为三个返回实时时间的函数:
highgo=# select statement_timestamp();
      statement_timestamp      
-------------------------------
 2017-06-21 13:57:27.246504+08
(1 row)


highgo=# select clock_timestamp();
        clock_timestamp        
-------------------------------
 2017-06-21 13:57:35.847353+08
(1 row)


highgo=# select timeofday();
              timeofday              
-------------------------------------
 Wed Jun 21 13:57:49.782139 2017 CST
(1 row)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值