<<<<<<< HEAD current_catalog | H2 | SQLDoc
Skip to main content

current_catalog

1. CURRENT_CATALOG Function

======= current_catalog | H2 Function | SQLDoc

current_catalog

1. CURRENT_CATALOG Function

>>>>>>> 9d19b1c8cb744c8e86d5c15b74d8b5f719ad62be

The CURRENT_CATALOG function in H2 database is used to retrieve the name of the current catalog (database) in use.

2. Syntax

The syntax for the CURRENT_CATALOG function in H2 database is as follows:

CURRENT_CATALOG()

Arguments

  • This function does not accept any arguments.

Return

  • The CURRENT_CATALOG function returns the name of the current catalog (database) as a string.

3. Notes

  • The CURRENT_CATALOG function in H2 database is useful when working with multiple catalogs (databases) within the same session.
  • If no catalog (database) has been explicitly set, this function returns the default catalog of the current session.
  • The name of the current catalog is returned as a string, so it can be used in other SQL statements or queries.

4. Examples

Here are a few examples demonstrating the usage of the CURRENT_CATALOG function in H2 database:

Example 1 - Retrieving the current catalog:

SELECT CURRENT_CATALOG() AS current_catalog;

Output:

current_catalog
----------------
PUBLIC

Example 2 - Using the current catalog in a query:

SELECT * FROM CURRENT_CATALOG()..EMPLOYEES;

Output:

+------+------------+---------+
| ID | NAME | SALARY |
+------+------------+---------+
| 1 | John Smith | 5000.0 |
| 2 | Jane Doe | 6000.0 |
+------+------------+---------+
  • current_schema - Retrieve the name of the current schema.
  • DATABASE - Retrieve the name of the current database (catalog).
  • SCHEMA - Retrieve the name of the current schema.