RE: [GENERAL] How to find names of tables in a database? - Mailing list pgsql-general

From Jackson, DeJuan
Subject RE: [GENERAL] How to find names of tables in a database?
Date
Msg-id F10BB1FAF801D111829B0060971D839F475DF2@cpsmail
Whole thread Raw
Responses Re: [GENERAL] How to find names of tables in a database?
Re: [GENERAL] How to find names of tables in a database?
List 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

pgsql-general by date:

Previous
From: La Mancha de la Calabaza que Ladra
Date:
Subject: Re:
Next
From: "Gene Selkov Jr."
Date:
Subject: Re: [GENERAL] How to find names of tables in a database?