Re: [SQL] How do I get column names?

From: neko(at)kredit(dot)sth(dot)szif(dot)hu
To: "Steven M(dot) Wheeler" <swheeler(at)sabre(dot)com>
Cc: pgsql-sql(at)hub(dot)org
Subject: Re: [SQL] How do I get column names?
Date: 1999-12-14 01:13:12
Message-ID: Pine.LNX.4.10.9912140143180.5706-100000@kredit.sth.szif.hu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Mon, 13 Dec 1999, Steven M. Wheeler wrote:

> A simple question.
>
> What is the best way to query the DB, to get the column names for a
> particular table?
SELECT attname FROM pg_attribute, pg_class WHERE pg_class.oid = attrleid
AND attnum>0 AND relname = 'particular_table';
In this way, in each tuple of the result can find a column name.
Or can use the simple:
SELECT * FROM particular_table LIMIT 1;
This query will be return with a single line, and you can get the column
names from the result. (PQfname).

The first way may a bit faster, but the second can work with user typed
querys too.

Best Regards
--
nek;(

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Stoyan Genov 1999-12-14 10:49:58 SQL'92 web resources
Previous Message Mathijs Brands 1999-12-14 00:33:51 Re: [SQL] System Attribute