Sample Header Ad - 728x90

How to get the name of the current database from within PostgreSQL?

219 votes
6 answers
329809 views
Using \c in PostgreSQL will connect to the named database. How can the name of the current database be determined? Entering: my_db> current_database(); produces: ERROR: syntax error at or near "current_database" LINE 1: current_database();
Asked by Amelio Vazquez-Reina (2315 rep)
Feb 5, 2014, 09:16 PM
Last activity: Jan 15, 2025, 09:28 AM