setting MySQL field uid as auto_increment
For some reason i keep getting the following error when i try to set my uid as auto_increment. I am using phpMyAdmin.
Error
SQL query:
ALTER TABLE `ITEMS` ADD `uid` INT( 2 ) NOT NULL AUTO_INCREMENT FIRST ,
ADD `name` VARCHAR( 100 ) NOT NULL AFTER `uid` ,
ADD `status` VARCHAR( 100 ) NOT NULL AFTER `name`
MySQL said: Documentation
#1075 - Inco开发者_Go百科rrect table definition; there can be only one auto column and it must be defined as a key
I had a few other tables in my database that originally had index as auto_increment but I changed all those columns to uid varchar. But now I am adding a table named ITEMS and I want uid to be the "master" key that I can use as a reference point to all my other tables.
You need to add the PRIMARY KEY constraint to your new column. BTW, this may mean removing that constraint from any old column that was originally AUTO_INCREMENT.
You're not adding a table, but changing it. New specification comes in conflict with what exists in the schema, you can do show table and post it here for us to see.
精彩评论