Re: Querying the field types of a table

From: Lamar Owen <lamar(dot)owen(at)wgcr(dot)org>
To: Charles Tassell <ctassell(at)isn(dot)net>
Cc: Dale Anderson <danderso(at)crystalsugar(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Querying the field types of a table
Date: 2000-05-10 19:22:25
Message-ID: 3919B6F1.CA5DA884@wgcr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Charles Tassell wrote:
> archives you will find more detail. Generally, the best way to find what
> you are looking for is to start psql with the -E option (echo queries sent

> At 03:30 PM 5/10/00, Dale Anderson wrote:
> >Is there a way to query the field names and types of a table in either 6.5
> >or 7.0?? I am writing an application, and in one piece, I need to get the
> >field names and field types of any table. Can this be done??? I have
> >searched both the web and documentation, and I can't seem to find a C
> >function or system table that has this information.

$tablename = table to query.

SELECT a.attname, t.typname
FROM pg_class c, pg_attribute a, pg_type t
WHERE c.relname = '$tablename'
and a.attnum >0 and a.attrelid = c.oid
and a.tttypid = t.oid
ORDER BY attname

--
Lamar Owen
WGCR Internet Radio
1 Peter 4:11

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ganah 2000-05-10 19:44:23 Beginner with Timestamp
Previous Message Charles Tassell 2000-05-10 18:47:39 Re: Querying the field types of a table