2 Ways to Show all Databases in PostgreSQL

Last updated on January 29, 2022 A Goodman Loading... Post a comment

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:

psql -l

Or:

psql --list

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:

Via pgAdmin

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:

Conclusion

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:

You can also check out our database topic page for the latest tutorials and examples.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments

Related Articles