Overview

The CURRENT_SCHEMA() function returns the name of the first existing schema.

It will return NULL if none of the schemas from search_path exist.

Syntax

CURRENT_SCHEMA() function has the following syntax:

SELECT CURRENT_SCHEMA();

Another method is to omit the parenthesis from the above syntax.

SELECT CURRENT_SCHEMA;
It does not require any argument to operate.

Example

The following example shows how to get the current schema name using CURRENT_SCHEMA() function.

SELECT CURRENT_SCHEMA();

The final result will display the schema that you currently use:

+------------+
| f          |
+------------+
| public     |
+------------+