How do I get a list of DB's or Tables with a postgres SQL statement?

Started by Ron de Jongabout 24 years ago3 messages
#1Ron de Jong
radejong@planet.nl

All,

How do I get a list of DB's or Tables with a postgres SQL statement?
It needs to be an SQL statement otherwise perl/DBI/prepare won't parse it.
I know there is some funtions in psql:

\l (show databases)
\d (show tables)

which work fine from psql, but these
statements won't be parsed by perl, DBI

I also know there is an object:

@names = $dbh->tables;

but what about databases?

Please help.

Ron de Jong
the Netherlands

#2Alessio Bragadini
alessio@albourne.com
In reply to: Ron de Jong (#1)
Re: How do I get a list of DB's or Tables with a postgres SQL statement?

Ron de Jong wrote:

I know there is some funtions in psql:

\l (show databases)
\d (show tables)

If you start psql with the -E option, it will show you which queries it
makes to the internal tables to retrieve the backslash result. Then
copying and customizing your own query is very simple.

--
Alessio F. Bragadini alessio@albourne.com
APL Financial Services http://village.albourne.com
Nicosia, Cyprus phone: +357-2-755750

"It is more complicated than you think"
-- The Eighth Networking Truth from RFC 1925

#3Lee Kindness
lkindness@csl.co.uk
In reply to: Ron de Jong (#1)

See the pg_database table:

http://www.postgresql.org/idocs/index.php?catalog-pg-database.html

Regards, Lee.

Ron de Jong writes:

Show quoted text

All,

How do I get a list of DB's or Tables with a postgres SQL statement?
It needs to be an SQL statement otherwise perl/DBI/prepare won't parse it.
I know there is some funtions in psql:

\l (show databases)
\d (show tables)

which work fine from psql, but these
statements won't be parsed by perl, DBI

I also know there is an object:

@names = $dbh->tables;

but what about databases?

Please help.

Ron de Jong
the Netherlands

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html