-- 添加新列
ALTER TABLE your_table
ADD COLUMN new_column INT;
-- 填充数据从1开始
UPDATE your_table
SET new_column = (SELECT @rownum := @rownum + 1 FROM (SELECT @rownum := 0) r);
自动填充主键
最新推荐文章于 2024-08-31 23:40:08 发布
-- 添加新列
ALTER TABLE your_table
ADD COLUMN new_column INT;
-- 填充数据从1开始
UPDATE your_table
SET new_column = (SELECT @rownum := @rownum + 1 FROM (SELECT @rownum := 0) r);