RE: [GENERAL] How to find names of tables in a database?

From: "Jackson, DeJuan" <djackson(at)cpsgroup(dot)com>
To: Valerie Mates <popcorn(at)tir(dot)com>, pgsql-general(at)postgreSQL(dot)org
Subject: RE: [GENERAL] How to find names of tables in a database?
Date: 1998-10-14 20:53:49
Message-ID: F10BB1FAF801D111829B0060971D839F475DF2@cpsmail
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> Hi -- I've been dabbling in PostgreSQL on and off for a few months
> now. At
> this point I can get it to do a number of neat things, but I've run
> into
> one that is a stumper.
>
> I'm looking for a way that my Perl program can look up the names of
> the
> tables in a database. Is there a way to do this? I've looked through
> the
> documentation on the PostgreSQL website, but didn't find any way to do
> this. It seems like there must be a query like "SELECT table_names
> FROM
> my_database" to do this, but if there is, I haven't found it yet.
>
> (My apologies if this has been discussed recently. I was on this
> mailing
> list for a while, but have been off it for a month or so.)
>
> Thanks for any help you can offer!
>
> -Valerie Mates
I thought for sure this was on the FAQ...
What you are looking for is the behavior of psql's \dt command.
You can look at the psql source to get the exact query, but it's
something like this:
SELECT * FROM pg_class
The \dt command filters out the system (WHERE rel_name NOT LIKE 'pg_%')
tables and some other things so I'd look at it otherwise you get a few
hundred tables in an empty database.
-DEJ

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Gene Selkov Jr. 1998-10-14 20:57:08 Re: [GENERAL] How to find names of tables in a database?
Previous Message La Mancha de la Calabaza que Ladra 1998-10-14 20:31:12 Re: