CURRENT_CATALOG

Return the name of the catalog (top-level database) bound to the current session.

Category: miscReturns: STRINGDialect: Standard

Syntax

CURRENT_CATALOG()

Description

## Overview Returns the name of the current catalog for the session. DeltaForge uses a three-part name hierarchy (catalog.schema.table), and the catalog is the top level of that hierarchy. Use this function to emit fully qualified identifiers, to filter metadata views to the active catalog, or to include context in audit columns. CURRENT_DATABASE is a synonym. ## Session context - The value is the catalog name that the session is currently using, as set at connection time or by a subsequent `USE CATALOG` statement. - Takes no arguments; both `CURRENT_CATALOG` and `CURRENT_CATALOG()` are accepted. - Never returns NULL. ## Behavior - Always returns a non-NULL string. - Deterministic for the duration of the current catalog binding. - Side effect free. ## Compatibility - Matches the SQL-standard CURRENT_CATALOG.

Examples

-- Read the active catalog
SELECT CURRENT_CATALOG();
-- Include catalog context in diagnostic output
SELECT CURRENT_CATALOG() AS catalog,
       CURRENT_SCHEMA() AS schema_name,
       CURRENT_USER()   AS user_name;
-- Restrict information_schema browsing to the current catalog
SELECT table_name
FROM information_schema.tables
WHERE table_catalog = CURRENT_CATALOG();
-- Build a fully qualified name at query time
SELECT CURRENT_CATALOG() || '.' || CURRENT_SCHEMA() || '.events' AS fqn;

Pitfalls

See Also

Open in interactive docs →   DeltaForge home →