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

目录
相关文章
|
BI API 数据处理
带你理解并使用flink中的Time、Window(窗口)、Windows Function(窗口函数)
flink中,streaming流式计算被设计为用于处理无限数据集的数据处理引擎,其中无限数据集是指一种源源不断有数据过来的数据集,window (窗口)将无界数据流切割成为有界数据流进行处理的方式。实现方式是将流分发到有限大小的桶(bucket)中进行分析。flink 中的streaming定义了多种流式处理的时间,Event Time(事件时间)、Ingestion Time(接收时间)、Processing Time(处理时间)。
505 0
带你理解并使用flink中的Time、Window(窗口)、Windows Function(窗口函数)
|
Python
[oeasy]python0024_ 输出时间_time_模块_module_函数_function
[oeasy]python0024_ 输出时间_time_模块_module_函数_function
78 0
[oeasy]python0024_ 输出时间_time_模块_module_函数_function
|
Oracle 关系型数据库 数据库
|
14天前
|
资源调度 Serverless 计算机视觉
高斯函数 Gaussian Function
**高斯函数,或称正态分布,以数学家高斯命名,具有钟形曲线特征。关键参数包括期望值μ(决定分布中心)和标准差σ(影响分布的宽度)。当μ=0且σ²=1时,分布为标准正态分布。高斯函数广泛应用于统计学、信号处理和图像处理,如高斯滤波器用于图像模糊。其概率密度函数为e^(-x²/2σ²),积分结果为误差函数。在编程中,高斯函数常用于创建二维权重矩阵进行图像的加权平均,实现模糊效果。
14 1
|
27天前
|
算法 Serverless C语言
CMake函数和宏(function和macro):使用函数和宏提高代码可读性
CMake函数和宏(function和macro):使用函数和宏提高代码可读性
30 1
|
27天前
|
存储 安全 编译器
【C++ 包装器类 std::function 和 函数适配器 std::bind】 C++11 全面的std::function和std::bind的入门使用教程
【C++ 包装器类 std::function 和 函数适配器 std::bind】 C++11 全面的std::function和std::bind的入门使用教程
32 0
|
1月前
|
SQL Oracle 关系型数据库
Flink的表值函数(Table-Valued Function,TVF)是一种返回值是一张表的函数
【2月更文挑战第17天】Flink的表值函数(Table-Valued Function,TVF)是一种返回值是一张表的函数
20 1
|
6月前
|
存储 数据安全/隐私保护
均匀散列函数(Uniform Hash Function)
均匀散列函数(Uniform Hash Function)是一种将不同长度的输入数据映射到相同大小的输出数据的散列函数。均匀散列函数的主要特点是,对于相同的输入数据,无论其长度如何,都会得到相同的输出散列值。这种散列函数常用于数据结构的存储和查找,例如哈希表、散列表等。
97 3
|
3月前
|
存储 SQL 安全
函数(Function)和存储过程(Stored Procedure)的区别(小白情感版)
函数(Function)和存储过程(Stored Procedure)的区别(小白情感版)
29 0
|
3月前
|
缓存
pytest 运行测试函数报错的解决办法 TypeError: calling <function xxx> returned None, not a test
pytest 运行测试函数报错的解决办法 TypeError: calling <function xxx> returned None, not a test
77 0

热门文章

最新文章