Using \c <database_name> 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();
CALL. – Eerik Sven Puudist Sep 28 '21 at 13:52SELECT current_user, the fact thatcurrent_databaseis a function is surprising. – Steve Chavez Apr 25 '23 at 04:19current_useras a magic keyword. Postgres does not want to expand the set of keywords, so anything not specified by the standard tends to be added as functions. – Craig Ringer May 22 '23 at 03:35