current_database()

A function returning the name of the current database

current_database() is a system function returning the name of the current database.

current_database() was added in PostgreSQL 7.3.

Usage

current_database () → name

current_catalog is provided as an SQL-standard equivalent.

Change history

Examples

Execution of current_database():

postgres=# SELECT current_database();
 current_database
------------------
 postgres
(1 row)

postgres=# \c template1
You are now connected to database "template1" as user "postgres".

template1=# SELECT current_database();
 current_database
------------------
 template1
(1 row)

Categories

System function

See also

current_catalog, current_schema(), current_user