1. Home
  2. PostgreSQL
  3. Tutorials
  4. SHOW DATABASES

SHOW DATABASES

List Databases in PostgreSQL

In PostgreSQL \list or \l command is used for listing databases in server. Login to PostgreSQL database command prompt using command ‘sudo -u postgres psql‘ from terminal.

Command :-

postgres=# \list

Examples :-

Login to your PostgreSQL server using command line. You will get PostgreSQL database prompt like postgres=# . Now use execute l or list command to list all databases.

Using list Command:

postgres=# \list


                             List of databases
   Name    |  Owner   | Encoding | Collate | Ctype |   Access privileges
-----------+----------+----------+---------+-------+-----------------------
 mydb      | postgres | UTF8     | en_IN   | en_IN |
 postgres  | postgres | UTF8     | en_IN   | en_IN |
 template0 | postgres | UTF8     | en_IN   | en_IN | =c/postgres          +
           |          |          |         |       | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_IN   | en_IN | =c/postgres          +
           |          |          |         |       | postgres=CTc/postgres
(4 rows)

Using l Command:

postgres=# \l 


                             List of databases
   Name    |  Owner   | Encoding | Collate | Ctype |   Access privileges
-----------+----------+----------+---------+-------+-----------------------
 mydb      | postgres | UTF8     | en_IN   | en_IN |
 postgres  | postgres | UTF8     | en_IN   | en_IN |
 template0 | postgres | UTF8     | en_IN   | en_IN | =c/postgres          +
           |          |          |         |       | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_IN   | en_IN | =c/postgres          +
           |          |          |         |       | postgres=CTc/postgres
(4 rows)
Tags ,
Was this article helpful to you? Yes No
Advertisement