begin;
CREATE TABLE IF NOT EXITS temp_table LIKE table;
ALTER TABLE `temp_table` MODIFY COLUMN `id` INT NOT NULL AUTO_INCREMENT FIRST,
ADD PRIMARY KEY ( `id` );
INSERT INTO temp_table ( url, title, time, info, source, html, type ) SELECT
url,title,time,info,source,html,type FROM table;
DELETE FROM table WHERE 1 = 1;
ALTER TABLE `table` MODIFY COLUMN `id` INT NOT NULL AUTO_INCREMENT FIRST,
ADD PRIMARY KEY ( `id` );
INSERT INTO table SELECT * FROM temp_table;
SELECT * FROM temp_table;
SELECT * FROM table;
commit;
mysql 更新历史数据Id为自增
于 2023-03-29 01:02:56 首次发布