CURRENT_DATABASE

functionsupportedAccounts, users, sessions, warehouses

docs.snowflake.com ↗

Context functions

Returns the name of the current database, which varies depending on where you call the function: - If you call this function outside of a policy, UDF, or view, it returns the database that is in use for the current session. - If you call this function in the body of a policy, for example a masking policy, it returns the database that contains the table or view that is protected by the policy. - If you call this function in the handler code of a UDF, it returns the database that contains the UDF. - If you call this function in the definition of a view, it returns the database that contains the view.

Syntax

CURRENT_DATABASE()

Usage notes