Mark Riehl <[EMAIL PROTECTED]> wrote:
> All - Running MySQL 4.0.17 under Red Hat 9, using MyISAM tables.
> 
> I'm trying to add the auto_increment attribute to column in a table that 
> already has a primary key defined.  Here is the table I'm trying to create:
> 
> 
> CREATE TABLE IF NOT EXISTS dataTypes (
> id int unsigned NOT NULL AUTO_INCREMENT KEY,
> dataType varchar(64) PRIMARY KEY,
> description tinytext,
> dbName tinytext,
> directory tinytext,
> updated timestamp,
> UNIQUE (dataType))
> 
> This create statement works w/o the id column.  However, when I add the 
> id column, I get an error on table creation.  Is it complaining because 
> it thinks I'm trying to add a second primary key (since all of the 
> AUTO_INCREMENT attribute ints are unique)?
> 
> What's the easiest way to do this?

You can use KEY as synonym for PRIMARY KEY only from version 4.1. But you can't have 
more than one PRIMARY KEY in the table.
If you want to create index on AUTO_INCREMENT column, you can do it like:
        
        CREATE TABLE IF NOT EXISTS dataTypes (
        id int unsigned NOT NULL AUTO_INCREMENT,
        ....
        ....
        INDEX (id),
        ....
        );


-- 
For technical support contracts, goto https://order.mysql.com/?ref=ensita
This email is sponsored by Ensita.net http://www.ensita.net/
   __  ___     ___ ____  __
  /  |/  /_ __/ __/ __ \/ /    Victoria Reznichenko
 / /|_/ / // /\ \/ /_/ / /__   [EMAIL PROTECTED]
/_/  /_/\_, /___/\___\_\___/   MySQL AB / Ensita.net
       <___/   www.mysql.com





-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to