Return the name of the schema (namespace) bound to the current session.
CURRENT_SCHEMA()
## Overview Returns the name of the current schema for the session. The schema is the middle level in the three-part name hierarchy (catalog.schema.table). Use this function to build fully qualified identifiers, to scope information_schema queries, or to include context in audit output. ## Session context - The value is the schema the session is currently using, as set at connection time or by `SET SCHEMA` / `USE SCHEMA`. - Takes no arguments; both `CURRENT_SCHEMA` and `CURRENT_SCHEMA()` are accepted. - Never returns NULL. ## Behavior - Always returns a non-NULL string. - Deterministic for the duration of the current binding. - Side effect free. ## Compatibility - Matches the SQL-standard CURRENT_SCHEMA.
-- Read the active schema
SELECT CURRENT_SCHEMA();
-- Build a fully qualified table reference
SELECT CURRENT_CATALOG() || '.' || CURRENT_SCHEMA() || '.events' AS fqn;
-- Session diagnostics snapshot
SELECT CURRENT_DATABASE() AS db, CURRENT_SCHEMA() AS schema_name, CURRENT_USER() AS user_name;
-- Limit information_schema browsing to the active schema
SELECT table_name FROM information_schema.tables
WHERE table_schema = CURRENT_SCHEMA();