LOCALTIMESTAMP

Returns a value of type TIMESTAMP that represents the start of the current transaction.

The return value does not change during the transaction. Thus, multiple calls to LOCALTIMESTAMP within the same transaction return the same timestamp.

Behavior Type

Stable

Syntax

LOCALTIMESTAMP [ ( precision ) ]

Parameters

precision

Rounds the result to the specified number of fractional digits in the seconds field.

Example

=> CREATE TABLE t1 (a int, b int);
CREATE TABLE

=> INSERT INTO t1 VALUES (1,2);
 OUTPUT
--------
      1
(1 row)

=> SELECT CURRENT_TIMESTAMP(2) timestamp;
         timestamp
---------------------------
 2016-12-07 15:19:12.34-05
(1 row)

=> INSERT INTO t1 VALUES (3,4);
 OUTPUT
--------
      1
(1 row)

=> SELECT CURRENT_TIMESTAMP(2) timestamp;
         timestamp
---------------------------
 2016-12-07 15:19:12.34-05
(1 row)

=> COMMIT;
COMMIT
=> SELECT CURRENT_TIMESTAMP(2) timestamp;
         timestamp
---------------------------
 2016-12-07 15:19:13.89-05
(1 row)