Context Functions

This family of functions allows gathering information about the context in which the statement is executed. These functions are evaluated at most once per statement.

In this Topic:

List of Functions

Sub-category Function Notes
General Context CURRENT_CLIENT  
CURRENT_DATE  
CURRENT_TIME  
CURRENT_TIMESTAMP  
CURRENT_VERSION  
LOCALTIME Alias for CURRENT_TIME.
LOCALTIMESTAMP Alias for CURRENT_TIMESTAMP.
Session Context CURRENT_SESSION  
CURRENT_STATEMENT  
CURRENT_TRANSACTION  
CURRENT_USER  
LAST_QUERY_ID  
LAST_TRANSACTION  
Session Object Context CURRENT_DATABASE  
CURRENT_ROLE  
CURRENT_SCHEMA  
CURRENT_SCHEMAS  
CURRENT_WAREHOUSE  

Usage Notes

  • Context functions do not have any arguments.
  • To comply with ANSI standards, the following context functions can be called without parentheses:
    • CURRENT_DATE
    • CURRENT_TIME
    • CURRENT_TIMESTAMP
    • CURRENT_USER
    • LOCALTIME
    • LOCALTIMESTAMP

Examples

Display the current warehouse, database, and schema for the session:

SELECT CURRENT_WAREHOUSE(), CURRENT_DATABASE(), CURRENT_SCHEMA();

---------------------+--------------------+------------------+
 CURRENT_WAREHOUSE() | CURRENT_DATABASE() | CURRENT_SCHEMA() |
---------------------+--------------------+------------------+
 MY_WAREHOUSE        | MY_DB              | PUBLIC           |
---------------------+--------------------+------------------+

Display the current date, time, and timestamp (note that parentheses are not required to call these functions):

SELECT CURRENT_DATE, CURRENT_TIME, CURRENT_TIMESTAMP;

--------------+--------------+---------------------------------+
 CURRENT_DATE | CURRENT_TIME |        CURRENT_TIMESTAMP        |
--------------+--------------+---------------------------------+
 2015-04-28   | 17:43:46     | Tue, 28 Apr 2015 17:43:46 -0700 |
--------------+--------------+---------------------------------+