Skip to main content

Context Functions

This page provides reference information for the context-related functions in Databend. These functions return information about the current session, database, or system context.

Session Information Functions​

FunctionDescriptionExample
CONNECTION_IDReturns the connection ID for the current connectionCONNECTION_ID() → 42
CURRENT_USERReturns the user name and host for the current connectionCURRENT_USER() → 'root'@'%'
LAST_QUERY_IDReturns the query ID of the last executed queryLAST_QUERY_ID() → '01890a5d-ac96-7cc6-8128-01d71ab8b93e'

Database Context Functions​

FunctionDescriptionExample
CURRENT_CATALOGReturns the name of the current catalogCURRENT_CATALOG() → 'default'
DATABASEReturns the name of the current databaseDATABASE() → 'default'

System Information Functions​

FunctionDescriptionExample
VERSIONReturns the current version of DatabendVERSION() → 'DatabendQuery v1.2.252-nightly-193ed56304'
Try Databend Cloud for FREE

Multimodal, object-storage-native warehouse for BI, vectors, search, and geo.

Snowflake-compatible SQL with automatic scaling.

Sign up and get $200 in credits.

Try it today