Re: getting attribute names, types - Mailing list pgsql-general

From Michael Fuhr
Subject Re: getting attribute names, types
Date
Msg-id 20050307035056.GA23219@winnie.fuhr.org
Whole thread Raw
In response to getting attribute names, types  ("Surabhi Ahuja " <surabhi.ahuja@iiitb.ac.in>)
List pgsql-general
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/

pgsql-general by date:

Previous
From: "Greg Sabino Mullane"
Date:
Subject: Re: Error: "catalog is missing 8 attribute(s) for relid 16683"
Next
From: Michael Fuhr
Date:
Subject: Re: Pg 8.01 big trouble with LIMIT (bug !?)