用mysql 语句实现id自增,添加主键

发布时间:2012-12-04 09:18:18

 

1、ALTER TABLE `domain_dns_tucows` ADD PRIMARY KEY(`id`);

如果以前有主键的话: ALTER TABLE `domain_dns_tucows` DROP PRIMARY KEY, ADD PRIMARY KEY(`id`);

2、ALTER TABLE `domain_dns_tucows` CHANGE `id` `id` INT(11) NOT NULL AUTO_INCREMENT;

ps:顺序不能变哦,不然没法自增。