homepage Welcome to WebmasterWorld Guest from 54.234.225.23
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderator: open

Databases Forum

    
Help Adding An Auto Increment Column into a table
Might be phpmyadmin, mysql version problem.
rj87uk




msg:3569907
 6:58 pm on Feb 8, 2008 (gmt 0)

Hey All,

Need a little help - I have done this several times with no problems however when I updated my computer I am now getting errors.

I have a table with values Town,Region I now wish to add in an Auto_Increment column into this table. I use id, int 11, not null, auto_increment & select Primary Key. I click save and get this error:


SQL query:

ALTER TABLE `cities` ADD `id` INT( 11 ) NOT NULL AUTO_INCREMENT FIRST

MySQL said: Documentation
#1075 - Incorrect table definition; there can be only one auto column and it must be defined as a key

I am using: phpMyAdmin - 2.11.3 & MySQL client version: 5.0.51

It works fine on: phpMyAdmin - 2.8.0.3 & MySQL client version: 5.0.20.

Any ideas?

 

yumigator




msg:3570107
 10:57 pm on Feb 8, 2008 (gmt 0)

"#1075 - Incorrect table definition; there can be only one auto column and it must be defined as a key"

That's the problem. Only one column may be auto_increment. Is there any particular reason you need two? Generally, auto_increment is just used to generate unique id's for each row.

LifeinAsia




msg:3570119
 11:12 pm on Feb 8, 2008 (gmt 0)

Also see [webmasterworld.com...]

rj87uk




msg:3570176
 1:08 am on Feb 9, 2008 (gmt 0)

Thanks yumigator & LifeInAsia,

I just double checked but there is no other primary field & also says in phpmyadmin "No index defined!" I am sure there is no auto_increment.

I can do all of this in the previous version of phpmyadmin/mysql however when I updated it started giving me this error, so any help?

RJ

rocknbil




msg:3570433
 3:53 pm on Feb 9, 2008 (gmt 0)

alter table cities add id int(11) primary key auto_increment not null;

rj87uk




msg:3570439
 4:16 pm on Feb 9, 2008 (gmt 0)

Hi rocknbil,

You are my hero. One question I have is why did it not add that into the mysql statement even when I clicked the "primary key" checkbox in phpmyadmin?

Thanks - It works!

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved