Re: SQL query: List all the databases in the server

From: Vince Vielhaber <vev(at)michvhf(dot)com>
To: Roman Smirnov <smirnov(at)dresearch(dot)de>
Cc: PostgreSQL conferention <pgsql-docs(at)postgresql(dot)org>
Subject: Re: SQL query: List all the databases in the server
Date: 2001-07-03 11:44:19
Message-ID: Pine.BSF.4.30.0107030740100.56876-100000@paprika.michvhf.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

On Tue, 3 Jul 2001, Roman Smirnov wrote:

> Hi all!
>
> I need SQL analog of \l command from psql.
> Something like "list databases".

If you just want a list of them you can get it from pg_database:

select datname from pg_database;

if you also want the username of the database owner you'll have to
cross pg_database.datdba to pg_user.usesysid something like this:

select d.datname,u.usename from pg_database d, pg_user u where d.datdba = u.usesysid;

Vince.
--
==========================================================================
Vince Vielhaber -- KA8CSH email: vev(at)michvhf(dot)com http://www.pop4.net
56K Nationwide Dialup from $16.00/mo at Pop4 Networking
Online Campground Directory http://www.camping-usa.com
Online Giftshop Superstore http://www.cloudninegifts.com
==========================================================================

In response to

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message Justin Clift 2001-07-03 11:54:19 Re: replication
Previous Message Roman Smirnov 2001-07-03 11:15:45 SQL query: List all the databases in the server