PostgreSQL – How to Retrieve the Current Database Name

To get the name of the current database in PostgreSQL, you can use the following SQL query:

SELECT current_database();

When you execute this query, it will return the name of the database that you are currently connected to.

For example, if you are connected to a database named “my_database,” executing the query will return “my_database” as the result.

Similar Posts