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
How to use Oracle and PostgreSQL query in one select query - Stack Overflow
In my Java program, I am trying to take values from a PostgreSQL database and using this data I am using a Select query with an Oracle database. More on stackoverflow.com
🌐 stackoverflow.com
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.
🌐
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.
🌐
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.
🌐
PostgreSQL
postgresql.org › docs › 9.5 › sql-select.html
PostgreSQL: Documentation: 9.5: SELECT
December 13, 2021 - Note that if a FROM clause is not specified, the query cannot reference any database tables. For example, the following query is invalid: SELECT distributors.* WHERE distributors.name = 'Westward'; PostgreSQL releases prior to 8.1 would accept queries of this form, and add an implicit entry to the query's FROM clause for each table referenced by the query.
🌐
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.
🌐
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)
🌐
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.
🌐
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.