By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,809 Members | 1,999 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,809 IT Pros & Developers. It's quick & easy.

Any way to SELECT a list of table names?

P: n/a
Is there any way in Postgres to SELECT a list of table names from inside of
a C program using ECPG?
Something similar to SELECT current_user that will give you all of the
tables in the database you are connected to.

__________________________________________________ _______________
High-speed usersóbe more efficient online with the new MSN Premium Internet
Software. http://join.msn.com/?pgmarket=en-us&page=byoa/prem&ST=1
---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 12 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a

Eric Freeman schrieb:
Is there any way in Postgres to SELECT a list of table names from inside
of a C program using ECPG?
Something similar to SELECT current_user that will give you all of the
tables in the database you are connected to.


I guess you are looking for the information stored in pg_tables:

http://www.postgresql.org/docs/curre...pg-tables.html

Thomas


---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 12 '05 #2

P: n/a
On Sat, 10 Jan 2004, Eric Freeman wrote:
Is there any way in Postgres to SELECT a list of table names from inside of
a C program using ECPG?
Something similar to SELECT current_user that will give you all of the
tables in the database you are connected to.


If you are running 7.4 and have the information_schema you can use that to
find out just about anything.
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 12 '05 #3

P: n/a
> On Sat, 10 Jan 2004, Eric Freeman wrote:

Is there any way in Postgres to SELECT a list of table names from inside of
a C program using ECPG?
Something similar to SELECT current_user that will give you all of the
tables in the database you are connected to.


Not sure if this is what you're trying to do but.......

"SELECT tablename FROM pg_tables where tablename not like 'pg_%'"

Will get a list of tables in the db you're connected to.
---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 12 '05 #4

P: n/a
From: "Ken Godee" <ke*@perfect-image.com>
Not sure if this is what you're trying to do but.......

"SELECT tablename FROM pg_tables where tablename not like 'pg_%'"

Will get a list of tables in the db you're connected to.

You can do that, but if by any chance, the pg_catalog schema changes, you
may find your app broken. The pg_catalog schema is not really intended to
be a client interface, so if you go that way, you may want to wrap it in a
function :-)

Now, if you are using PostgreSQL 7.4, use this query instead:

select table_name, table_schema from information_schema.tables where
table_schema NOT IN ('pg_catalog', 'information_schema');

Best wishes,
Chris Travers
---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 22 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.