I have just managed to migrate a pretty big database from SQL Server to MySQL. I didn't set the primary keys to auto increment during the migration because the tables have relationships based on ids as primary keys which are foreign keys in another table.
Now for adding new records I want to alter the primary key 'id' columns in all tables to be autoincrement but starting from the last highest number in the id column in each table.
What's the best way to do this without losing the relationships I already have?
UPDATE: Trying to add autoincrement gives me this error:
ERROR 1067: Invalid default value for 'id'
SQL Statement:
ALTER TABLE `skandium`.`brands` CHANGE COLUMN `id` `id` INT(11) NOT NULL DEFAULT '0' AUTO_INCREMENT
ERROR 1050: Table 'brands' already exists
SQL Statement:
CREATE TABLE `brands` (
`id` int(11) NOT NULL DEFAULT '0',
`brand` varchar(50) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1