Re: column name with plpgsql

From: Raymond O'Donnell <rod(at)iol(dot)ie>
To: Alain Roger <raf(dot)news(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: column name with plpgsql
Date: 2009-02-07 14:32:43
Message-ID: 498D9B8B.5090003@iol.ie
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 07/02/2009 14:26, Alain Roger wrote:

> i have a table which can be altered with several additional column. How can
> i test under plpgsql if a particular column already exists ?

select 1 from information_schema.columns
where table_name = 'your_table_name_here'
and column_name = 'your_column_name_here';

HTH,

Ray.

------------------------------------------------------------------
Raymond O'Donnell, Director of Music, Galway Cathedral, Ireland
rod(at)iol(dot)ie
Galway Cathedral Recitals: http://www.galwaycathedral.org/recitals
------------------------------------------------------------------

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alain Roger 2009-02-07 14:35:14 Re: column name with plpgsql
Previous Message Grzegorz Jaśkiewicz 2009-02-07 14:31:33 Re: column name with plpgsql