> 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))

Sorry to jump emails, but i missed/deleted the first one, I don't know if i
would build the table this way, but this CREATE will work.

CREATE TABLE IF NOT EXISTS dataTypes(
id int unsigned NOT NULL AUTO_INCREMENT ,
dataType varchar( 64 ) PRIMARY KEY ,
description tinytext,
dbName tinytext,
directory tinytext,
updated timestamp,
UNIQUE (dataType),
KEY ( id )
)

By default the PRIMARY KEY can never be duplicated, so the unique is
redundant (i think???).  Maybe you really want the combo of the first two
as your primary key?

hth
Jeff


>
> 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?
>
> Thanks,
> Mark
>
>

Already tested with phpMyAdmin ?

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







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

Reply via email to