CURRENT_TIMESTAMP()

Documentation

VoltDB Home » Documentation » Using VoltDB

CURRENT_TIMESTAMP()

CURRENT_TIMESTAMP() — Returns the current time as a timestamp value.

Synopsis

CURRENT_TIMESTAMP()

CURRENT_TIMESTAMP

Description

The CURRENT_TIMESTAMP() function returns the current time as a VoltDB timestamp. The value of the timestamp is determined when the query or stored procedure is invoked. Since there are no arguments to the function, the parentheses following the function name are optional.

Several important aspects of how the CURRENT_TIMESTAMP() function operates are:

  • The value returned is guaranteed to be identical for all partitions that execute the query.

  • The value returned is measured in milliseconds then padded to create a timestamp value in microseconds.

  • During command logging, the returned value is stored as part of the log, so when the command log is replayed, the same value is used during the replay of the query.

  • Similarly, for database replication (DR) the value returned is passed and reused by the replica database when replaying the query.

  • You can specify CURRENT_TIMESTAMP() as a default value in the CREATE TABLE statement when defining the schema of a VoltDB database.

  • The CURRENT_TIMESTAMP() function cannot be used in the CREATE INDEX or CREATE VIEW statements.

The NOW() and CURRENT_TIMESTAMP() functions are synonyms and perform an identical function.

Example

The following example uses CURRENT_TIMESTAMP() in the WHERE clause to delete alert events that occurred in the past:

DELETE FROM Alert_event WHERE event_timestamp < CURRENT_TIMESTAMP;