X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A1DDCD9935 for ; Tue, 27 Sep 2005 09:46:19 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 32169-03 for ; Tue, 27 Sep 2005 12:46:09 +0000 (GMT) Received: from zrtps0kp.nortelnetworks.com (zrtps0kp.nortelnetworks.com [47.140.192.56]) by svr1.postgresql.org (Postfix) with ESMTP id CD28BD98E4 for ; Tue, 27 Sep 2005 09:46:06 -0300 (ADT) Received: from zrtps0m6.us.nortel.com (zrtps0m6.us.nortel.com [47.140.192.58]) by zrtps0kp.nortelnetworks.com (Switch-2.2.6/Switch-2.2.0) with ESMTP id j8RCk7O21132; Tue, 27 Sep 2005 08:46:07 -0400 (EDT) Received: from cash.rhiamet.com (rhiamet.us.nortel.com [47.103.243.53]) by zrtps0m6.us.nortel.com (Switch-2.2.6/Switch-2.2.0) with ESMTP id j8RCk3l27290; Tue, 27 Sep 2005 08:46:03 -0400 (EDT) Received: from cash.rhiamet.com (bmetcalf@localhost [127.0.0.1]) by cash.rhiamet.com (8.13.4/8.13.4/Debian-3) with ESMTP id j8RCjxok016204; Tue, 27 Sep 2005 07:46:00 -0500 Received: from localhost (bmetcalf@localhost) by cash.rhiamet.com (8.13.4/8.13.4/Submit) with ESMTP id j8RCjxp7016200; Tue, 27 Sep 2005 07:45:59 -0500 X-Authentication-Warning: cash.rhiamet.com: bmetcalf owned process doing -bs Date: Tue, 27 Sep 2005 07:45:59 -0500 (CDT) From: "Brandon Metcalf" X-X-Sender: bmetcalf@cash.rhiamet.com To: Peter Eisentraut Cc: pgsql-sql@postgresql.org Subject: Re: add column if doesn't exist In-Reply-To: <200509270216.05141.peter_e@gmx.net> Message-ID: References: <200509270216.05141.peter_e@gmx.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.265 required=5 tests=[AWL=0.215, FORGED_RCVD_HELO=0.05] X-Spam-Level: X-Archive-Number: 200509/263 X-Sequence-Number: 22810 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