From: sheeri kritzer Date: May 25 2006 1:24am Subject: Re: How do I add a column only if it doesn't exist? List-Archive: http://lists.mysql.com/mysql/198284 Message-Id: <24cb9b4b0605241824r540a7f5ag15897f1a856ca71@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable I don't think MySQL can do that....maybe with some kind of stored procedure= .... If you're using 5.0 or higher, use the INFORMATION SCHEMA to find out if the column exists. If not, use the "show create table" statement and parse it. Why is this a problem, though? (just curious, I'm not sure this would ever come up. I don't do automatic schema changes, always do them manually, so I'm not too sure why you'd be amiss....unless you're running gobs of servers and some of them have the column and some of them don't.....but even then you could run a script that alters the table to add the column and just let it thrown an error if it already exists.) -Sheeri On 5/24/06, Daevid Vincent wrote: > I want to do something like this: > > if not exists `hotel_page_templates`.`hpt_custom_fields` > alter table `hotel_page_templates` add column `hpt_custom_fields` text af= ter > `hpt_alternate_username`; > > > =D0=C65=CF=D0 > > > -- > MySQL General Mailing List > For list archives: http://lists.mysql.com/mysql > To unsubscribe: http://lists.mysql.com/mysql?unsub=3Dawfief@stripped > >