PostgreSQL – Switching between databases

You can connect to a different database from within the psql prompt using below command where databasename is the name of the database that you would like to connect to.

\CONNECT databasename;

\c is the short for \connect . Below command can also be used to connect to a different database from within the psql prompt.

\C databasename;

You can also connect with a different role while switching between databases using below syntax:

\CONNECT databasename rolename;
or
\c databasename rolename;

See also  PostgreSQL - Change Owner of Tablespace