You can find out which PostgreSQL database is currently selected by using either of the following:
SELECT current_catalog;
-- or
SELECT * FROM current_catalog;
SELECT current_database();
-- or
SELECT * FROM current_database();
Both of them are synonymous to each other and do the same thing. current_catalog() is considered the standard though, because databases are called "catalogs" in the SQL standard.
It will produce an output like the following:
+------------------+
| current_database |
+------------------+
| db_name |
+------------------+