Skip site navigation (1) Skip section navigation (2)

Re: Finding column using SQL query.

From: "Rajan Bhide" <rbhide(at)starentnetworks(dot)com>
To: <pgsql-novice(at)postgresql(dot)org>, <email(at)juergen-cappel(dot)de>
Cc: "Santosh Bhujbal" <sbhujbal(at)starentnetworks(dot)com>,"Sachin Ahire" <sahire(at)starentnetworks(dot)com>
Subject: Re: Finding column using SQL query.
Date: 2005-02-09 11:10:54
Message-ID: FF851C7EEB75954F9BCFB5CA117AB1EC013FE34D@delta.nulinkinc.com (view raw or flat)
Thread:
Lists: pgsql-novice
I tried finding relation between pg_attribute and pg_class but seems
there is no common key between these two table.

select * from pg_attribute where attrelid = (select reltype from
pg_class  where relname = 'mytablename';
 attrelid | attname | atttypid | attstattarget | attlen | attnum |
attndims | at
tcacheoff | atttypmod | attbyval | attstorage | attisset | attalign |
attnotnull
 | atthasdef
----------+---------+----------+---------------+--------+--------+------
----+---
----------+-----------+----------+------------+----------+----------+---
--------
-+-----------
(0 rows)


So this is not solving my problem.
Am I missing somethg or there is some other way to find out?
Plz comment.

Thanks,
Rajan

-----Original Message-----
From: email(at)juergen-cappel(dot)de [mailto:email(at)juergen-cappel(dot)de] 
Sent: Wednesday, February 09, 2005 3:38 PM
To: Rajan Bhide
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: [NOVICE] Finding column using SQL query.



Take a look at the system catalogs:

http://www.postgresql.org/docs/8.0/interactive/catalogs.html

HTH



Rajan Bhide <rbhide(at)starentnetworks(dot)com> schrieb am 09.02.2005,
10:56:20:
> Hi,
> 
> Is there any way to find whether a particular column exists in the 
> table or not based on the column name using sql query? I have a 
> requirement where I need to find whether a column exists in the table 
> or not using SQL query.
> 
> Thanks,
> Rajan
> 
> ---------------------------(end of 
> broadcast)---------------------------
> TIP 9: the planner will ignore your desire to choose an index scan if
your
>       joining column's datatypes do not match

pgsql-novice by date

Next:From: emailDate: 2005-02-09 11:32:01
Subject: Re: RE: Finding column using SQL query.
Previous:From: Schuhmacher, BretDate: 2005-02-09 11:03:54
Subject: Re: Duration betweeen 2 timestamps

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group