CURRENT_TIMESTAMP Function
Function Description
The CURRENT_TIMESTAMP
function is a non-deterministic function used to return the timestamp at the start of the current query execution. Within the same query, no matter how many times the CURRENT_TIMESTAMP
function is called, the returned timestamp is the same. This function is very useful for recording the start time of query execution, especially in time-sensitive data analysis and transaction processing.
Parameter Description
No parameters need to be provided.
Return Type
This function returns a timestamp of type timestamp_ltz
.
Usage Example
- Query the current timestamp:
The execution result:
- Record the current timestamp when inserting data:
This statement will use the current timestamp as the value for the created_at
field when inserting a new record.
- Compare the difference between the timestamps before and after the query:
This will record the start and end timestamps of the query separately, which can be used to analyze the execution time of the query.
- Use in conjunction with time intervals to calculate future or past points in time:
The execution result: