Please note the following commands:

  • \list or \l: list all databases
  • \c <db name>: connect to a certain database
  • \dt: list all tables in the current database using your search_path
  • \dt *.: list all tables in the current database regardless your search_path

You will never see tables in other databases, these tables aren't visible. You have to connect to the correct database to see its tables (and other objects).

To switch databases:

\connect database_name or \c database_name

See the manual about psql.

Answer from Frank Heikens on Stack Exchange
🌐
Neon
neon.com › postgresql › administration › show-databases
PostgreSQL Show Databases
The query returns four databases in the current PostgreSQL server. Use \l or \l+ in psql to show all databases in a PostgreSQL database server.
Discussions

postgresql - How to list databases in terminal in PostgresSQL? - Stack Overflow
Show activity on this post. I'm experienced with MySQL, but I've just started to work with Postgres - from the terminal, how can I see the list of existing Postgres databases using the psql command? More on stackoverflow.com
🌐 stackoverflow.com
Get a list of available PostgreSQL databases
I can get a list of available PostgreSQL databases in Terminal by using: psql -h 127.0.0.1 -l Can I do that in Xojo without using a shell? More on forum.xojo.com
🌐 forum.xojo.com
1
0
December 10, 2022
show tables in current database using psql
Maybe those tables aren't in the search path? You can use \dn to show all schemas (=namespaces). Then you can e.g. use \dt some_schema.* to show the tables in one specific schema. More on reddit.com
🌐 r/PostgreSQL
7
1
June 15, 2024
Dumb question - postgresql db file location?
Actually, as a database user you should not bother where the files are stored. As a user your only way to access the database is through SQL. Only db admins might use access to the data files (many!). More on reddit.com
🌐 r/PostgreSQL
12
9
December 31, 2019
🌐
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
Each database is stored as a separate set of files in its own directory within the server’s data directory. To view all of the defined databases on the server you can use the \list meta-command or its shortcut \l.
🌐
Xojo Programming Forum
forum.xojo.com › targets › macos
Get a list of available PostgreSQL databases - macOS - Xojo Programming Forum
December 10, 2022 - I can get a list of available PostgreSQL databases in Terminal by using: psql -h 127.0.0.1 -l Can I do that in Xojo without using a shell?
🌐
DB Vis
dbvis.com › thetable › postgres-list-databases
How To List Databases in PostgreSQL: A Complete Guide
February 5, 2025 - As shown here, a database client ... can list databases in PostgreSQL using the following approaches: Command-line: Run l or list inside the psql ......
Find elsewhere
🌐
Hasura
hasura.io › blog › top-psql-commands-and-flags-you-need-to-know-postgresql
Top psql commands and flags you need to know | PostgreSQL
The \dn psql command lists all the database schemas. It returns the name of the schemas and their owners. Sometimes, you might need to change the user. Postgres has a command that lists all the users and their roles.
🌐
GeeksforGeeks
geeksforgeeks.org › postgresql › postgresql-show-databases
PostgreSQL - Show Databases - GeeksforGeeks
2 weeks ago - The SHOW DATABASES command is used to retrieve and display all databases accessible to the current user in a DBMS.
🌐
PostgreSQL
postgresql.org › docs › current › app-psql.html
PostgreSQL: Documentation: 18: psql
May 14, 2026 - The optional topic parameter (defaulting to options) selects which part of psql is explained: commands describes psql's backslash commands; options describes the command-line options that can be passed to psql; and variables shows help about psql configuration variables. psql returns 0 to the shell if it finished normally, 1 if a fatal error of its own occurs (e.g., out of memory, file not found), 2 if the connection to the server went bad and the session was not interactive, and 3 if an error occurred in a script and the variable ON_ERROR_STOP was set. psql is a regular PostgreSQL client application. In order to connect to a database you need to know the name of your target database, the host name and port number of the server, and what database user name you want to connect as.
🌐
QUADED
quaded.com › главная страница › postgresql: show databases list
PostgreSQL: show databases list
May 10, 2020 - Connect to the PostgreSQL via psql [root@s ~]# su postgres bash-4.4$ psql psql (10.6) Type "help" for help. postgres=# List the databases – l postgres=# l List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges -----------+----------+----------+-------------+-----...
🌐
Dataedo
dataedo.com › kb › query › postgresql › list-databases
List databases on PostgreSQL instance - PostgreSQL Data Dictionary Queries
select oid as database_id, datname as database_name, datallowconn as allow_connect, datconnlimit as connection_limit from pg_database order by oid;
🌐
Reddit
reddit.com › r/postgresql › show tables in current database using psql
r/PostgreSQL on Reddit: show tables in current database using psql
June 15, 2024 -

Hello, I'm running a psql command inside of my postgres container. When running the \dt to show my database tables it's always giving me "Did not find any relations". Im pretty new in psql commands, am I missing something?

🌐
Medium
medium.com › the-table-sql-and-devtalk › three-easy-ways-to-list-databases-in-postgresql-07d51775d8ae
Three Easy Ways to List Databases in PostgreSQL | The Table — Databases and SQL
June 13, 2024 - Learn how to list databases in PostgreSQL using command-line tools, queries, and database clients. Discover the best method for your needs.
🌐
W3Schools
w3schools.com › sql › sql_drop_db.asp
SQL DROP DATABASE Statement
April 30, 2026 - Tip: Once a database is dropped, you can check that it is removed from the list of databases with: SHOW DATABASES; (MySQL) or SELECT name FROM sys.databases; (SQL Server).
🌐
Sqlnosql
sqlnosql.com › how-to-list-postgres-database
List Postgres Databases – Database Tutorial
postgres=# \l List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges -----------+----------+----------+--------------------+--------------------+----------------------- postgres | postgres | UTF8 | English_India.1252 | English_India.1252 | template0 | postgres | UTF8 | English_India.1252 | English_India.1252 | =c/postgres + | | | | | postgres=CTc/postgres template1 | postgres | UTF8 | English_India.1252 | English_India.1252 | =c/postgres + | | | | | postgres=CTc/postgres (3 rows) postgres=# \l+ List of databases Name | Owner | Encoding | Collate | Ctype | Access privil
🌐
Heroku
heroku.com › home › pricing
Cloud Application Platform Pricing & Plans | Heroku
January 10, 2025 - Heroku Postgres: Delivers the world’s most advanced open-source database as a trusted, secure, and scalable service optimized for developers, ensuring data integrity and performance.
🌐
Rill
rilldata.com › blog › introducing-metrics-sql-a-sql-based-semantic-layer-for-humans-and-agents
Introducing Metrics SQL: A SQL-based semantic layer for humans and agents | Rill
If databases like DuckDB, ClickHouse, Snowflake understood MEASURE as a first-class SQL keyword, a metrics view could be a native database object stored alongside existing table metadata, and all compilation and query optimizations would move into the engine itself. ... Zero-hop metrics queries: Tools like psql could query metrics directly from database without any middleware
🌐
AlexHost
alexhost.com › home › faq › administration › listing and switching databases in postgresql: the complete technical guide
Listing and Switching Databases in PostgreSQL: The Complete Technical Guide
October 24, 2024 - PostgreSQL manages multiple isolated databases within a single server instance, each with its own schema, roles, and privileges. To list all databases, run l inside psql or query SELECT datname FROM pg_catalog.pg_database; from any session.
🌐
Fog Hosting
foghosting.com › home › how to list all databases in postgresql? - fog hosting
How to List All Databases in PostgreSQL? – Fog Hosting - Fog Hosting
February 19, 2025 - Introduction Navigating through databases is a fundamental skill for PostgreSQL users, and understanding how to list databases is key to efficient database management. In this comprehensive guide, we’ll delve into various methods to list all databases in PostgreSQL, addressing diverse preferences ...