Timestamp function
timestamp(columnName)
elects a
designated timestamp:
- during a CREATE TABLE operation
- during a SELECT operation (
dynamic timestamp
) - when ingesting data via ILP, for tables that do not already exist in QuestDB, partitions are applied automatically by day by default with a
timestamp
column
info
Checking if tables contain a designated timestamp column can be done via the
tables()
and table_columns()
functions which are described in the
meta functions documentation page.
#
Syntax#
During a CREATE operationCreate a designated timestamp column during table creation. For more information, refer to the CREATE TABLE section.
#
During a SELECT operationCreates a designated timestamp column in
the result of a query. Assigning a timestamp in a SELECT
statement
(dynamic timestamp
) allows for time series operations such as LATEST BY
,
SAMPLE BY
or LATEST BY
on tables which do not have a designated timestamp
assigned.
#
Examples#
During a CREATE operationThe following creates a table with designated timestamp.
#
During a SELECT operationThe following will query a table and assign a
designated timestamp to the output. Note
the use of brackets to ensure the timestamp clause is applied to the result of
the query instead of the whole readings
table.
Although the readings
table does not have a designated timestamp, we are able
to create one on the fly. Now, we can use this into a subquery to perform
timestamp operations.
If the data is unordered, it is important to order it first.