I'm not sure you can auto_increment a field after the fact.  In any case, it
looks like your problem is that you have duplicate data in the field you are
trying to auto_increment.  Spin through the table and make sure that all
rows are unique on that field. THEN try to auto_increment it. (Which still
might fail)

If it still fails then try creating a new table with the same structure but
with that field auto_incremented.  Then load that table with the data from
the old table. Drop the old table and rename the new one.

HTH,
Cal
http://www.calevans.com


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 26, 2001 2:44 PM
To: [EMAIL PROTECTED]
Subject: using ALTER TABLE to make existing column AUTO_INCREMENT ??


ive gotten along pretty well with mysql and online docs.  but now i
am stumped and hoping for a little kick in the right direction.

i have a column in a table which is the primary key and is an int.
how do i make it also be auto_increment?  the table already has some
data in it, so i suspect that this may be where my problem comes from.
when i use ALTER TABLE (my best guess at how to do it), i get this error:

  mysql> alter table fixtures modify column id int auto_increment;
  ERROR 1062: Duplicate entry '1' for key 1

perhaps i need to somehow start things up with the next highest
auto increment  .. or ...?


thanks,
-jon

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to