NOW()

Documentation

VoltDB Home » Documentation » Using VoltDB

NOW()

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

Synopsis

NOW()

NOW

Description

The NOW() 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 NOW() 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 NOW() as a default value in the CREATE TABLE statement when defining the schema of a VoltDB database.

  • The NOW() 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 NOW(0 in the WHERE clause to delete alert events that occurred in the past:

DELETE FROM Alert_event WHERE event_timestamp < NOW;