Lamer Moments: Listing databases in PostgreSQL 1

Posted by Joshua Schmidlkofer Wed, 14 Dec 2005 18:46:00 GMT

In MySQL you can use 'show databases' along with many other convenient 'show' commands. PostgreSQL is a different beast entirely. using real databases can be challenging if you grew up on MySQL.

Connect to the database with psql:

psql -U postgres template1
opsdb ~ # psql -U postgres template1
Welcome to psql 8.0.3, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help with psql commands
       \g or terminate with semicolon to execute query
       \q to quit

template1=# select datname from pg_database;
   datname
--------------
 template1
 template0
 mydb
 typo
(4 rows)

template1=# quit


Update: [2005-12-16]

After MANY people have pointed out that "dude" \L works in the Interactive Interface. I would like to tell you: This is useless when you are actually using PostgreSQL from within programs / scripts.
Comments

Leave a comment

  1. Avatar
    pacopablo 2 days later:
    wanker, you made my comment useless
Comments