Thread: Any way to SELECT a list of table names?
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
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/current/static/view-pg-tables.html Thomas
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.
> 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.
From: "Ken Godee" <ken@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