libpq: possible to get list of tables, fields, and types?
using libpq, is it possible to get a list of tables (psql: \d equivalent),
list of fields for each of those tables (psql: \d <table>), and types for
each of the fields for a given container?
there doesnt seem to be a way to do any of these, except for getting the
field type of a returned tuple with PQftype() and looking up the returned
oid in the pg_attribute.
it does appear to be possible to query system tables (psql: \dS) for some
of this data, such as pg_tables for a list of tables. yet there doesnt
appear to be a way to associate these entries to a particular datbase
container. am i missing some way to glue these tables together to get a
list of tables per-container and fields per-table?
tia,
-heas
john heasley wrote:
using libpq, is it possible to get a list of tables (psql: \d equivalent),
list of fields for each of those tables (psql: \d <table>), and types for
each of the fields for a given container?there doesnt seem to be a way to do any of these, except for getting the
field type of a returned tuple with PQftype() and looking up the returned
oid in the pg_attribute.it does appear to be possible to query system tables (psql: \dS) for some
of this data, such as pg_tables for a list of tables. yet there doesnt
appear to be a way to associate these entries to a particular datbase
container. am i missing some way to glue these tables together to get a
list of tables per-container and fields per-table?tia,
-heas---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
Hi,
yes - system tables is the right answer.
pg_tables is a view on pg_class. And pg_class has the information you
need. Look into the developers guide for a description of systemtables.
Information about the attributes are in pg_attribute. Just join it with
pg_class:
select relname, attname, atttypid, attlen from pg_attribute join
pg_class on attrelid = pg_class.oid
A good source for information is pgaccess. It is a TCL-script. You can
find examples in the source.
Tommi
select relname, attname, atttypid, attlen from pg_attribute join
pg_class on attrelid = pg_class.oid
This gives all the attributes of a given table, but I couldn't find any join
giving all the tables of a particular database ( no dboid in pg_class ).
Did someone here found this kind of join ?
--
cordialement, William WAISSE fpr = 9CCD 7DA2 7050 8805 F471 03D1 DF76 B78C
690B 4E07
--
Computers are like air conditionners. They work better when you close windows.
--
Visitez donc mon site perso (version 0.4 du 29/05/2001) :
http://www.neofutur.net
--
Vous habitez dans l'Essonne et vous aimez les Pingouins ???
visitez donc la GAULE(=LUG91) : http://www.gaule.org
-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GCS/E/MU d- s: a- C++++ UL+++ P+ L++++ E--- W++ N o-- K- w---
O- M- V- PS+ PE-- Y++ PGP++ t+ 5 X++ R++ tv- b+++ DI- D G e++ h* r++ y+++
------END GEEK CODE BLOCK------