Thread: table listing queries

table listing queries

From
Daniel Silverstone
Date:
Hi,

I know that questions like this have been asked in the past, but I can
find no definitive answer to one particular part of my problem...

Namely, in MySQL I can say: "SHOW TABLES FROM 'dbname'" to list tables
in a database I'm not currently connected to.

I can find no way of doing this in PgSQL.

Is there a way, or is postgres not letting me list the tables until I
have connected to the database for security reasons?

Thanks in advance,

D.

-- 
Daniel Silverstone                         http://www.digital-scurf.org/
PGP mail accepted and encouraged.            Key Id: 2BC8 4016 2068 7895




Re: table listing queries

From
Sean Davis
Date:
On 8/25/05 7:13 AM, "Daniel Silverstone" <dsilvers@digital-scurf.org> wrote:

> Hi,
> 
> I know that questions like this have been asked in the past, but I can
> find no definitive answer to one particular part of my problem...
> 
> Namely, in MySQL I can say: "SHOW TABLES FROM 'dbname'" to list tables
> in a database I'm not currently connected to.
> 
> I can find no way of doing this in PgSQL.
> 
> Is there a way, or is postgres not letting me list the tables until I
> have connected to the database for security reasons?

There are system catalogs which contain the information about tables.

http://www.postgresql.org/docs/8.0/interactive/catalogs.html

However, they are specific to each database.  In other words, the storage of
database-specific information is all WITHIN the given database, so you need
to be physically accessing the given database to even see those tables (or
do the query).  

Sean



Re: table listing queries

From
Hélder M. Vieira
Date:
> Namely, in MySQL I can say: "SHOW TABLES FROM 'dbname'" to list tables
> in a database I'm not currently connected to.

In MySQL, table definitions are replicated outside the database files, and 
might therefore be available without connecting to a specifc database.
This probably happens because of the need for some kind of unified 
repository of objects pertaining to different database engines.


Helder M. Vieira