Get list of tables in a database

Started by Nonameover 23 years ago4 messagesgeneral
Jump to latest
#1Noname
Riyaz@umapinc.com

Hi,

I am looking for a SQL query which will return me the names of all
the tables in a database. I want to use this in my php page to generate a
list of tables given the name of database.

Thanks in advance,
Riyaz

#2Philip Hallstrom
philip@adhesivemedia.com
In reply to: Noname (#1)
Re: Get list of tables in a database

% psql -E dbname
dbname=>\d

at the beginning of the output it will print out the query used to
generate the table list.

-E, --echo-hidden
Echoes the actual queries generated by \d and other
backslash commands. You can use this if you wish
to include similar functionality into your own pro-
grams. This is equivalent to setting the variable
ECHO_HIDDEN from within psql.

On Tue, 3 Dec 2002 Riyaz@umapinc.com wrote:

Show quoted text

Hi,

I am looking for a SQL query which will return me the names of all
the tables in a database. I want to use this in my php page to generate a
list of tables given the name of database.

Thanks in advance,
Riyaz

#3Oskar Berggren
beo@sgs.o.se
In reply to: Noname (#1)
Re: Get list of tables in a database

Riyaz@umapinc.com wrote:

Hi,

I am looking for a SQL query which will return me the names of all
the tables in a database. I want to use this in my php page to generate
a list of tables given the name of database.

Thanks in advance,
Riyaz

See FAQ item 4.3.

/Oskar

--
/----------------------------------------------------------------------\
| Oskar Berggren beo@sgs.o.se |
| Network and Software Engineer SGS Datan�tgrupp |
| Gothenburg, Sweden |
\----------------------------------------------------------------------/

#4SZŰCS Gábor
surrano@mailbox.hu
In reply to: Noname (#1)
Re: Get list of tables in a database

There is a relation called pg_class in PostgreSQL, but it contains not only
tables, but also contains views and probably more. Check it.

G.
--
while (!asleep()) sheep++;

---------------------------- cut here ------------------------------
----- Original Message -----
From: <Riyaz@umapinc.com>
Sent: Tuesday, December 03, 2002 9:12 PM

Show quoted text

Hi,

I am looking for a SQL query which will return me the names of all
the tables in a database. I want to use this in my php page to generate a
list of tables given the name of database.

Thanks in advance,
Riyaz