Thread: getting attribute names, types
i have to write a program in C++ using libpq. The program establishes a connection with the desired database.
I have 4 tables in the database. Now i want to get the list of attribute names, their data types for each of those 4 tables. how do i do that?
Thanks you
Surabhi Ahuja
On Thu, Mar 03, 2005 at 03:01:10PM +0530, Surabhi Ahuja wrote: > i have to write a program in C++ using libpq. The program > establishes a connection with the desired database. > I have 4 tables in the database. Now i want to get the list of > attribute names, their data types for each of those 4 tables. how > do i do that? You could query the system catalogs or the Information Schema (the latter available in 7.4 and later). Another way would be to query the tables themselves and use the functions described under "Retrieving Query Result Information" in the libpq documentation. http://www.postgresql.org/docs/8.0/interactive/catalogs.html http://www.postgresql.org/docs/8.0/interactive/information-schema.html http://www.postgresql.org/docs/8.0/interactive/libpq-exec.html#LIBPQ-EXEC-SELECT-INFO -- Michael Fuhr http://www.fuhr.org/~mfuhr/