Re: parsing relname in pg_class

From: Neil Conway <nconway(at)klamath(dot)dyndns(dot)org>
To: "Johnson, Shaunn" <SJohnson6(at)bcbsm(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: parsing relname in pg_class
Date: 2002-04-01 22:28:41
Message-ID: 20020401172841.7df4ff7e.nconway@klamath.dyndns.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, 1 Apr 2002 16:29:34 -0500
"Johnson, Shaunn" <SJohnson6(at)bcbsm(dot)com> wrote:
> I'm writing a perl script where I only want to parse
> out a list of tables from the database I'm connecting
> to.

If it's Perl with DBD, $dbh->tables() will get it for you.

> Is there an easier way to get a list of the tables ONLY
> with a select statement?

select * from pg_tables;

should do the trick. If you're not interested in system catalogs, filter
out all the relations that start with "pg_".

> I don't think I can pass a "\d"
> as a variable and get a return and I don't want to make
> a case statement for every possibility.

All these kinds of queries can be obtained by starting psql with "-E",
and then taking a look at how psql itself is getting the information.

Cheers,

Neil

--
Neil Conway <neilconway(at)rogers(dot)com>
PGP Key ID: DB3C29FC

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2002-04-01 23:02:10 Re: parsing relname in pg_class
Previous Message Andrew Sullivan 2002-04-01 22:06:17 Re: parsing relname in pg_class