From: Brandon Metcalf <bmetcalf@nortel.com>
To: Peter Eisentraut <peter_e@gmx.net>
Cc: pgsql-sql@postgresql.org
Subject: Re: add column if doesn't exist
Date: Tue, 27 Sep 2005 07:45:59 -0500 (CDT)
Message-ID: <Pine.LNX.4.58L.0509270732170.1453@cash.rhiamet.com> (raw)
In-Reply-To: <200509270216.05141.peter_e@gmx.net>
References: <Pine.LNX.4.58L.0509261534430.1453@cash.rhiamet.com>
<200509270216.05141.peter_e@gmx.net>
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 table
p> > other than, say, doing a SELECT on that column name and checking the
p> > 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: bmetcalf@nortel.com, peter_e@gmx.net
Subject: Re: add column if doesn't exist
In-Reply-To: <Pine.LNX.4.58L.0509270732170.1453@cash.rhiamet.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox