Re: add column if doesn't exist - Mailing list pgsql-sql

From Brandon Metcalf
Subject Re: add column if doesn't exist
Date
Msg-id Pine.LNX.4.58L.0509270732170.1453@cash.rhiamet.com
Whole thread Raw
In response to Re: add column if doesn't exist  (Peter Eisentraut <peter_e@gmx.net>)
List pgsql-sql
p == peter_e@gmx.net writes:
p> Brandon Metcalf wrote:p> > Is there a way to check for the existence of a column in a tablep> > other than, say,
doinga SELECT on that column name and checking thep> > output?
 
p> SELECT * FROM information_schema.columns;
p> Customize to taste.


Yes, that's what I'm looking for.  Thanks.

Now, is there a way to mix PostgreSQL commands and SQL and do
something like
 ALTER TABLE foo ADD COLUMN bar WHERE EXISTS(SELECT * FROM   information_schema.columns WHERE ...)

?

-- 
Brandon


pgsql-sql by date:

Previous
From: jeff sacksteder
Date:
Subject: Re: how to do 'deep queries'?
Next
From: Daryl Richter
Date:
Subject: Re: how to do 'deep queries'?