In PostgreSQL, you can use the \connect meta-command of the client tool psql:

\connect DBNAME

or in short:

\c DBNAME

Note that it is not possible to switch the current database via an SQL command, like you asked.

MySQL's USE DatabaseName is named somewhat confusingly, because what MySQL calls a "database" is more similar to what other systems (like Oracle or PostgreSQL) call a "schema" (and PostgreSQL also lets you access multiple schemas from a single SQL session). To quote the official documentation:

Users coming from an Oracle Database background may find that the MySQL meaning of a database is closer to what Oracle Database calls a schema.

Answer from Will Hartung on Stack Overflow
🌐
PostgreSQL
postgresql.org › docs › current › sql-select.html
PostgreSQL: Documentation: 18: SELECT
May 14, 2026 - SELECT SELECT, TABLE, WITH — retrieve rows from a table or view Synopsis [ WITH [ RECURSIVE ] with_query [, …
🌐
Vinchin
vinchin.com › home › database backup › how to select a database in postgresql using psql and gui tools?
How to Select a Database in PostgreSQL Using psql and GUI Tools? | Vinchin Backup
October 10, 2025 - This post describes what it means to select a database in PostgreSQL and explains 3 methods using psql, pgAdmin, and DBeaver. It also covers how to list databases.
Discussions

postgresql - How to switch databases in psql? - Stack Overflow
In PostgreSQL, you can use the \connect meta-command of the client tool psql: ... Note that it is not possible to switch the current database via an SQL command, like you asked. MySQL's USE DatabaseName is named somewhat confusingly, because what MySQL calls a "database" is more similar to what other systems (like Oracle ... More on stackoverflow.com
🌐 stackoverflow.com
postgresql - How do I merge database Oracle and Postgres into a Select? - Stack Overflow
I have DBeaver and 2 DB connections, Oracle and Postgres. I would like to know how do I use the 2 databases in my select? More on stackoverflow.com
🌐 stackoverflow.com
April 16, 2021
How to select a oracle table from postgresql script? - Stack Overflow
Thanks for the reply, Richard. Is there any step step process reference for PostgreSQL Database Link to Oracle Database on windows machine? More on stackoverflow.com
🌐 stackoverflow.com
May 23, 2017
Why is PostgreSQL becoming more popular than MySQL?
I switched from MySQL to Postgres when I learned about the powerful flexible data types. For example, Postgres can store geographic coordinates for latitude and longitude then do spatial searching. Postgres can also store schema-free data very well, such as storing key-value pairs using hstore, and storing JSON documents with a specialized type that provides many JSON operators. More on reddit.com
🌐 r/PostgreSQL
53
27
May 30, 2014
People also ask

Q1: Can I switch between multiple databases without disconnecting my session?
A1: No—you must disconnect then reconnect since each session links exclusively with one target DB at any given time in Postgres architecture.
🌐
vinchin.com
vinchin.com › home › database backup › how to select a database in postgresql using psql and gui tools?
How to Select a Database in PostgreSQL Using psql and GUI Tools?
Q3: What’s best way listing only application-specific (not template/system) databases quickly?
A3: Run this SQL snippet:SELECT datname FROM pg_database WHERE datistemplate = false AND datname NOT LIKE 'template%';
🌐
vinchin.com
vinchin.com › home › database backup › how to select a database in postgresql using psql and gui tools?
How to Select a Database in PostgreSQL Using psql and GUI Tools?
Q2: How do I confirm which exact database my terminal session points at now?
A2: TypeSELECT current_database();inside psql—or use command-line shortcut\conninfo—to display live details including host/user/database instantly onscreen.
🌐
vinchin.com
vinchin.com › home › database backup › how to select a database in postgresql using psql and gui tools?
How to Select a Database in PostgreSQL Using psql and GUI Tools?
🌐
TutorialsPoint
tutorialspoint.com › postgresql › postgresql_select_database.htm
PostgreSQL - SELECT Database
postgres-# \l List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges -----------+----------+----------+---------+-------+----------------------- postgres | postgres | UTF8 | C | C | template0 | postgres | UTF8 | C | C | =c/postgres + | | | | | postgres=CTc/postgres template1 | postgres | UTF8 | C | C | =c/postgres + | | | | | postgres=CTc/postgres testdb | postgres | UTF8 | C | C | (4 rows) postgres-# Now, type the following command to connect/select a desired database; here, we will connect to the testdb database.
🌐
PostgreSQL
postgresql.org › docs › current › tutorial-select.html
PostgreSQL: Documentation: 18: 2.5. Querying a Table
May 14, 2026 - ... Unsupported versions: 13 / 12 / 11 / 10 / 9.6 / 9.5 / 9.4 / 9.3 / 9.2 / 9.1 / 9.0 / 8.4 / 8.3 / 8.2 / 8.1 / 8.0 / 7.4 / 7.3 / 7.2 · To retrieve data from a table, the table is queried. An SQL SELECT statement is used to do this.
🌐
EnterpriseDB
enterprisedb.com › postgres-tutorials › using-select-query-data-single-table-and-multiple-tables
Using SELECT to query data from a single table and multiple tables | EDB
https://www.enterprisedb.com/e... the information from single table you can use the following format : Syntax : SELECT * FROM <table_name>; For example : SELECT * FROM emp; Output: To retrieve specific information from a ...
🌐
W3Schools
w3schools.com › postgresql › postgresql_select.php
PostgreSQL - Select Data
PostgreSQL CREATE TABLE PostgreSQL INSERT INTO PostgreSQL Fetch Data PostgreSQL ADD COLUMN PostgreSQL UPDATE PostgreSQL ALTER COLUMN PostgreSQL DROP COLUMN PostgreSQL DELETE PostgreSQL DROP TABLE Create Demo Database · PostgreSQL Operators PostgreSQL SELECT PostgreSQL SELECT DISTINCT PostgreSQL WHERE PostgreSQL ORDER BY PostgreSQL LIMIT PostgreSQL MIN and MAX PostgreSQL COUNT PostgreSQL SUM PostgreSQL AVG PostgreSQL LIKE PostgreSQL IN PostgreSQL BETWEEN PostgreSQL AS PostgreSQL Joins PostgreSQL INNER JOIN PostgreSQL LEFT JOIN PostgreSQL RIGHT JOIN PostgreSQL FULL JOIN PostgreSQL CROSS JOIN PostgreSQL UNION PostgreSQL GROUP BY PostgreSQL HAVING PostgreSQL EXISTS PostgreSQL ANY PostgreSQL ALL PostgreSQL CASE
Find elsewhere
🌐
Stack Overflow
stackoverflow.com › questions › 67132759 › how-do-i-merge-database-oracle-and-postgres-into-a-select
postgresql - How do I merge database Oracle and Postgres into a Select? - Stack Overflow
April 16, 2021 - But there would be a fair amount of work that the DBA of one or the other database would need to do in order to allow that. ... @JustinCave I want to create a link between Postgre and Oracle using DBeaver, to perform a Select and use data from the tables of each database.
🌐
PhoenixNAP
phoenixnap.com › home › kb › databases › how to list all databases in postgresql
How to List All Databases in PostgreSQL {3 Methods}
November 23, 2023 - Another method to list databases in PostgreSQL is to query database names from the pg_database catalog via the SELECT statement.
🌐
Stack Overflow
stackoverflow.com › questions › 28021279 › how-to-select-a-oracle-table-from-postgresql-script
How to select a oracle table from postgresql script? - Stack Overflow
May 23, 2017 - I need to access Oracle table from PostgreSQL script. I am trying to create a function in PostgreSQL to access oracle table's as input by select query. Please provide the process to achieve this.
🌐
Neon
neon.com › postgresql › administration › show-databases
PostgreSQL Show Databases
Use \l or \l+ in psql to show all databases in a PostgreSQL database server. Use the SELECT statement to query data from the pg_database to retrieve all the database names in a PostgreSQL database server.
🌐
Percona
percona.com › home › blog › bridging the gap: querying postgresql tables from an oracle database
Bridging the Gap: Querying PostgreSQL Tables from an Oracle Database - Percona
April 28, 2026 - Furthermore, this demo allows Oracle database administrators to learn PostgreSQL faster, and vice versa, bringing PostgreSQL closer to Oracle and adding practical knowledge for managers. ... Example: Run SELECT COUNT(*) FROM postgres_schema.table@PG_LINK directly in Oracle utility tools.
🌐
TutorialKart
tutorialkart.com › postgresql › postgresql-select-database
How to SELECT Database in PostgreSQL? Examples
October 23, 2024 - To SELECT a PostgresQL Database, you can open psql shell program and run the connection command to the database: c database. Or use pgAdmin UI to select postgresql database.
🌐
GeeksforGeeks
geeksforgeeks.org › postgresql › postgresql-show-databases
PostgreSQL - Show Databases - GeeksforGeeks
2 weeks ago - Now use the below command to list all databases using a superuser such as postgres: ... To list all databases by querying the pg_database system catalog using the SELECT statement.
🌐
Chat2DB
chat2db.ai › resources › blog › how-to-select-database-in-psql
How to Select a Database in PostgreSQL (psql) – Chat2DB
March 25, 2025 - This article serves as a comprehensive guide on efficiently selecting a database in PostgreSQL, focusing on its architecture, environment setup, command-line interface, connection processes, and the advantages of using tools like Chat2DB (opens in a new tab).
🌐
Atlassian
atlassian.com › data › admin › how to list databases and tables in postgresql using psql
How to List databases and tables in PostgreSQL using psql
1postgres=# \l 2 List of databases 3 Name | Owner | Encoding | Collate | Ctype | Access privileges 4-----------+----------+----------+-------------+-------------+----------------------- 5 postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | 6 sales | ubuntu | UTF8 | en_US.UTF-8 | en_US.UTF-8 | 7 template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres + 8 | | | | | postgres=CTc/postgres 9 template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres + 10 | | | | | postgres=CTc/postgres 11(4 rows)
🌐
CommandPrompt Inc.
commandprompt.com › education › how-to-selectaccess-a-database-in-postgresql
How to select/access a database in PostgreSQL — CommandPrompt Inc.
July 22, 2022 - ... There are multiple ways to select or access a PostgreSQL database, such as Command Prompt (cmd), SQL SHELL (psql), and pgAdmin 4. Type “\c” followed by a database name to select a database using psql.
Address   2950 Newmarket ST STE 101 - 231, 98226, Bellingham
🌐
Neon
neon.com › postgresql › postgresql-tutorial › postgresql-select
PostgreSQL SELECT
PostgreSQL evaluates the FROM clause before the SELECT clause in the SELECT statement: Note that the SQL keywords are case-insensitive. It means that SELECT is equivalent to select or Select. By convention, we will use all the SQL keywords in uppercase to make the queries easier to read. Let's explore some examples of using the SELECT statement. We will use the following customer table in the dvdrental sample database for the demonstration.
🌐
GeeksforGeeks
geeksforgeeks.org › postgresql › postgresql-select
PostgreSQL - SELECT - GeeksforGeeks
June 11, 2026 - SELECT statement is the primary command used to query data in PostgreSQL. It enables users to retrieve records from one or more tables, apply filtering conditions, sort and group results, limit returned rows, and generate summary information ...
🌐
SQLines
sqlines.com › postgresql › pgadmin › change_database
PostgreSQL pgAdmin - How to Change Database in Query Tool - SQLines Tools
In PostgreSQL you can work with a single database only, and there is no a USE dbname statement to change the database, you have to close the current connection and then connect to another database. ... Once you have connected to a database in the pgAdmin Query tool, you can select <new connection> and specify a new server and database: