2 Ways to Show all Databases in PostgreSQL
( 29 Articles)
This concise and straightforward article walks you through a couple of different ways to view all databases (on your server) in PostgreSQL.
Using psql command
The quick way
Open a terminal window on your computer then execute either of the following commands, whichever you like:
You may be asked for your password. Finally, you’ll get something like this:
A little bit more verbose
1. Log in to your PostgreSQL server with the psql command:
psql -U <your username> -p 5432
If your username is not postgres, you will be asked for the password. Enter it to continue.
2. You can now list all databases with one of the following commands:
- \list: List all databases with some basic information
- \l: The shortform of the command above
- \list+: List all databases with detailed information
- \l+: This is the shortform of the \list+ command
Here’s the result I received after running the \list command:
This’s what I got after running the \list+ command:
Note: If you don’t have pgAdmin installed, you can download it here.
If you prefer using the GUI (graphics user interface) to the command line, you can open your pgAdmin then head to Servers > localhost (you may have different servers, and their names may not be localhost as mine) > Databases, like so:
We’ve explored more than one approach to view all databases that were defined on our machines. If you’d like to learn more about Postgres and other database technologies, take a look at the following articles:
- PostgreSQL: Create Tables with Auto-Increment IDs
- Node + Mongoose + TypeScript: Defining Schemas and Models
- Using Docker Compose with Node.js and MongoDB
- How to Create/Delete a Database with MongoDB Shell
- How to see your MySQL version in macOS
- Ways to Store Data Offline in Flutter
You can also check out our database topic page for the latest tutorials and examples.