Getting a Database List

Started by Leeover 23 years ago5 messagesgeneral
Jump to latest
#1Lee
lee@dev.null.com

I need to know the interactive SQL syntax to get a listing of databases on
the current server.

Using Informix, the commands would be:
database sysmaster;
select name from sysdatabases;

MySQL:
show databases;

MS-SQL:
SELECT name FROM master..sysdatabases ORDER BY name

Please reply by posting to this newsgroup. My email address is hashed to
protect me from spamming.

Thanks,
Lee

#2Terry Fielder
terry@greatgulfhomes.com
In reply to: Lee (#1)
Re: Getting a Database List

You can use \l

Which is just an alias for the query:
SELECT d.datname as "Name",
u.usename as "Owner"
FROM pg_database d LEFT JOIN pg_user u ON d.datdba = u.usesysid
ORDER BY 1;

(in case you prefer to do the actual query)

Terry Fielder
Network Engineer
Great Gulf Homes / Ashton Woods Homes
terry@greatgulfhomes.com

Show quoted text

-----Original Message-----
From: pgsql-general-owner@postgresql.org
[mailto:pgsql-general-owner@postgresql.org]On Behalf Of Lee
Sent: Wednesday, July 24, 2002 10:55 PM
To: pgsql-general@postgresql.org
Subject: [GENERAL] Getting a Database List

I need to know the interactive SQL syntax to get a listing of
databases on
the current server.

Using Informix, the commands would be:
database sysmaster;
select name from sysdatabases;

MySQL:
show databases;

MS-SQL:
SELECT name FROM master..sysdatabases ORDER BY name

Please reply by posting to this newsgroup. My email address
is hashed to
protect me from spamming.

Thanks,
Lee

---------------------------(end of
broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

#3Martijn van Oosterhout
kleptog@svana.org
In reply to: Lee (#1)
Re: Getting a Database List

On Thu, Jul 25, 2002 at 10:55:04AM +0800, Lee wrote:

I need to know the interactive SQL syntax to get a listing of databases on
the current server.

psql -l

select * from pg_database; (IIRC)

Using Informix, the commands would be:
database sysmaster;
select name from sysdatabases;

MySQL:
show databases;

MS-SQL:
SELECT name FROM master..sysdatabases ORDER BY name

Please reply by posting to this newsgroup. My email address is hashed to
protect me from spamming.

--
Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/

Show quoted text

There are 10 kinds of people in the world, those that can do binary
arithmetic and those that can't.

#4Tom Jenkins
tjenkins@devis.com
In reply to: Lee (#1)
Re: Getting a Database List

Lee wrote:

I need to know the interactive SQL syntax to get a listing of databases on
the current server.

select * from pg_database;

while in psql you can do \dS (i believe) to get a list of system tables
and views.

Tom Jenkins

#5frbn
frbn@efbs-seafrigo.fr
In reply to: Lee (#1)
Re: Getting a Database List

Lee a écrit:

I need to know the interactive SQL syntax to get a listing of databases on
the current server.

Using Informix, the commands would be:
database sysmaster;
select name from sysdatabases;

MySQL:
show databases;

MS-SQL:
SELECT name FROM master..sysdatabases ORDER BY name

shell$ psql -E databasename
user$ \l