记录用。

向已存在的表中增加自增ID列

ALTER TABLE `table_name` ADD COLUMN `id` INT AUTO_INCREMENT UNIQUE FIRST;

把int列转换为timestamp

ALTER TABLE `table_name` ADD COLUMN `create_at2` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP();
UPDATE `table_name` SET `create_at2` = FROM_UNIXTIME(`create_at`);
ALTER TABLE `table_name` DROP COLUMN `create_at`;
ALTER TABLE `table_name` CHANGE `create_at2` `create_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP();
文章目录