tobyheywood
IS-IT--Management
Just a quick question,
I have a number of tables all with an id column. Now like an idiot I forgot to specify the auto_increment option and now need to add it.
I have a few test records in place which I don't want to lose!
I know I could dump the entire database to a file using mysqldump and manually edit the file, then finally drop the db and recreate it using the altered mysqldump file, but this to me is a little extreme.
i've been trying to use the following to alter the field definition;
and I receive the following;
Could someone please point out what it is I'm doing wrong or tell me a better way?
Regards
Toby Heywood
I have a number of tables all with an id column. Now like an idiot I forgot to specify the auto_increment option and now need to add it.
I have a few test records in place which I don't want to lose!
I know I could dump the entire database to a file using mysqldump and manually edit the file, then finally drop the db and recreate it using the altered mysqldump file, but this to me is a little extreme.
i've been trying to use the following to alter the field definition;
Code:
mysql> ALTER TABLE mn1 ALTER id id smallint unsigned not null primary key auto_increment;
and I receive the following;
Code:
ERROR 1064: You have an error in your SQL syntax near 'id smallint unsigned not null primary key auto_increment' at line 1
Could someone please point out what it is I'm doing wrong or tell me a better way?
Regards
Toby Heywood