Psqlgresql Time function时间函数

简介: Psqlgresql Time function时间函数 select now() 获取的时间为什么一直不变 pg中获取时间的方式有多种 如果放在事务中,now()获取的就是事务开始的时间,事务不结束,时间不变;而clock_timestamp()显示的时间会实时变化。

Psqlgresql Time function时间函数

select now() 获取的时间为什么一直不变?

pg中获取时间的方式有多种

如果放在事务中,now()获取的就是事务开始的时间,事务不结束,时间不变;而clock_timestamp()显示的时间会实时变化。获取时间行数参考如下:

now()
timestamp with time zone
Current date and time (start of current transaction); see Section 9.9.4

current_timestamp
timestamp with time zone
Current date and time (start of current transaction); see Section 9.9.4

current_time
time with time zone
Current time of day; see Section 9.9.4

clock_timestamp()
timestamp with time zone
Current date and time (changes during statement execution); see Section 9.9.4

eg:

postgres=# begin;
BEGIN
postgres=# select now();
              now              
-------------------------------
 2019-04-15 16:05:23.491101+08
(1 row)

postgres=# select now();
              now              
-------------------------------
 2019-04-15 16:05:23.491101+08
(1 row)

postgres=# end;
COMMIT
postgres=#


postgres=# begin;
BEGIN
postgres=# select clock_timestamp();
        clock_timestamp        
-------------------------------
 2019-04-15 16:04:20.491936+08
(1 row)
postgres=# select clock_timestamp();
        clock_timestamp        
-------------------------------
 2019-04-15 16:05:01.330757+08
(1 row)
postgres=# end;
COMMIT

reference

https://www.postgresql.org/docs/10/functions-datetime.html

目录
相关文章
|
4月前
|
Serverless 应用服务中间件 数据安全/隐私保护
Serverless 应用引擎操作报错合集之在阿里函数计算中,函数执行超时,报错Function time out after如何解决
Serverless 应用引擎(SAE)是阿里云提供的Serverless PaaS平台,支持Spring Cloud、Dubbo、HSF等主流微服务框架,简化应用的部署、运维和弹性伸缩。在使用SAE过程中,可能会遇到各种操作报错。以下是一些常见的报错情况及其可能的原因和解决方法。
|
BI API 数据处理
带你理解并使用flink中的Time、Window(窗口)、Windows Function(窗口函数)
flink中,streaming流式计算被设计为用于处理无限数据集的数据处理引擎,其中无限数据集是指一种源源不断有数据过来的数据集,window (窗口)将无界数据流切割成为有界数据流进行处理的方式。实现方式是将流分发到有限大小的桶(bucket)中进行分析。flink 中的streaming定义了多种流式处理的时间,Event Time(事件时间)、Ingestion Time(接收时间)、Processing Time(处理时间)。
641 0
带你理解并使用flink中的Time、Window(窗口)、Windows Function(窗口函数)
|
Python
[oeasy]python0024_ 输出时间_time_模块_module_函数_function
[oeasy]python0024_ 输出时间_time_模块_module_函数_function
93 0
[oeasy]python0024_ 输出时间_time_模块_module_函数_function
|
Oracle 关系型数据库 数据库
|
26天前
【Azure Durable Function】PowerShell Activity 函数遇见 Newtonsoft.Json.JsonReaderException: The reader's MaxDepth of 64 has been exceeded.
【Azure Durable Function】PowerShell Activity 函数遇见 Newtonsoft.Json.JsonReaderException: The reader's MaxDepth of 64 has been exceeded.
|
26天前
|
安全 JavaScript 应用服务中间件
【Azure Function App】如何修改Azure函数应用的默认页面呢?
【Azure Function App】如何修改Azure函数应用的默认页面呢?
|
27天前
|
C# C++ Python
【Azure 应用服务】Azure Durable Function(持久函数)在执行Activity Function时候,因为调用函数名称错误而导致长时间无响应问题
【Azure 应用服务】Azure Durable Function(持久函数)在执行Activity Function时候,因为调用函数名称错误而导致长时间无响应问题
|
26天前
|
SQL JavaScript 前端开发
【Azure 应用服务】Azure JS Function 异步方法中执行SQL查询后,Callback函数中日志无法输出问题
【Azure 应用服务】Azure JS Function 异步方法中执行SQL查询后,Callback函数中日志无法输出问题
|
26天前
|
JSON 数据格式 Python
【Azure 应用服务】Azure Function Python函数中,如何获取Event Hub Trigger的消息Event所属于的PartitionID呢?
【Azure 应用服务】Azure Function Python函数中,如何获取Event Hub Trigger的消息Event所属于的PartitionID呢?
|
26天前
|
C++ Python
【Azure 应用服务】Azure Function Python函数部署到Azure后遇见 Value cannot be null. (Parameter 'receiverConnectionString') 错误
【Azure 应用服务】Azure Function Python函数部署到Azure后遇见 Value cannot be null. (Parameter 'receiverConnectionString') 错误

热门文章

最新文章