New versions: Dev (3.14) | Latest (3.13) | 3.12 | 3.11 | 3.10 | 3.9 | 3.8 | Old versions: 3.7

CURRENT_SCHEMA

Applies to ✅ Open Source Edition   ✅ Express Edition   ✅ Professional Edition   ✅ Enterprise Edition

The CURRENT_SCHEMA() function produces the dialect dependent expression to produce the current default schema for the JDBC connection.

SELECT current_schema;
create.select(currentSchema()).fetch();

The result being, for example

+----------------+
| current_schema |
+----------------+
| public         |
+----------------+

Dialect support

This example using jOOQ:

currentSchema()

Translates to the following dialect specific expressions:

-- AURORA_MYSQL, MARIADB, MYSQL
DATABASE()

-- AURORA_POSTGRES, DB2, HSQLDB, POSTGRES
CURRENT_SCHEMA

-- CUBRID, FIREBIRD, SQLITE
''

-- DERBY
CURRENT SCHEMA

-- H2
SCHEMA()

-- ORACLE
user

-- SQLDATAWAREHOUSE, SQLSERVER
schema_name()

-- TERADATA
DATABASE

-- VERTICA
CURRENT_SCHEMA()

-- ACCESS, ASE, COCKROACHDB, HANA, INFORMIX, INGRES, MEMSQL, REDSHIFT, SYBASE
/* UNSUPPORTED */

(These are currently generated with jOOQ 3.14, see #10141)

The jOOQ Logo