[plug] auto-increment in mysql

Craig Ringer craig at postnewspapers.com.au
Wed Jan 1 21:37:25 WST 2003


> I have an existing table and I need to add another field and have this
> field set as a auto-increment field. Can anyone point me in the right
> direction?

ALTER TABLE tablename ADD COLUMN colname TYPENAME AUTO_INCREMENT;

thats the general idea, anyway. I mainly use postgresql these days so I 
may be a bit rusty. Hmm... when I tried it the db said:

mysql> ALTER TABLE test ADD COLUMN testing int AUTO_INCREMENT;
ERROR 1075: Incorrect table definition; There can only be one auto 
column and it must be defined as a key

so perhaps there's something I'm forgetting. Anyway, that should get you 
pointed in roughly the right direction.

Craig



More information about the plug mailing list