LOCALTIMESTAMP
返回 TIMESTAMP/TIMESTAMPTZ 类型值,代表当前事务的开始时间,并在事务关闭之前保持不变。因此,在给定事务中多次调用 LOCALTIMESTAMP 将返回相同的时间戳。
行为类型
稳定语法
LOCALTIMESTAMP [ ( precision ) ]
参数
- precision
- 将结果在秒字段中舍入到指定的小数位数。
示例
=> CREATE TABLE t1 (a int, b int);
CREATE TABLE
=> INSERT INTO t1 VALUES (1,2);
OUTPUT
--------
1
(1 row)
=> SELECT LOCALTIMESTAMP(2) AS 'local timestamp';
local timestamp
------------------------
2021-03-05 10:48:58.26
(1 row)
=> INSERT INTO t1 VALUES (3,4);
OUTPUT
--------
1
(1 row)
=> SELECT LOCALTIMESTAMP(2) AS 'local timestamp';
local timestamp
------------------------
2021-03-05 10:48:58.26
(1 row)
=> COMMIT;
COMMIT
=> SELECT LOCALTIMESTAMP(2) AS 'local timestamp';
local timestamp
------------------------
2021-03-05 10:50:08.99
(1 row)