List:General Discussion« Previous MessageNext Message »
From:Peter Brawley Date:September 26 2005 5:50pm
Subject:Re: add a column if not exists
View as plain text  
Claire,

 >I want to check if a column exists in a table before I
 >do an alter table to add it. How do I do this in
 >mysql? Thanks.

If you are using MySQL 5.0, query information_schema.columns 
(http://dev.mysql.com/doc/mysql/en/columns-table.html) for the table and 
column. Otherwise use SHOW COLUMNS FROM tablename.

PB
http://www.artfulsoftware.com

-----

Claire Lee wrote:

>I want to check if a column exists in a table before I
>do an alter table to add it. How do I do this in
>mysql? Thanks.
>
>Claire
>
>__________________________________________________
>Do You Yahoo!?
>Tired of spam?  Yahoo! Mail has the best spam protection around 
>http://mail.yahoo.com 
>
>  
>


-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.11.6/111 - Release Date: 9/23/2005

Thread
add a column if not existsClaire Lee26 Sep
  • Re: add a column if not existsPeter Brawley26 Sep
    • Re: add a column if not existsPooly26 Sep
  • Re: add a column if not existsGleb Paharenko27 Sep