mysql 如何给大表添加字段

2024-12-30 00:37:46
推荐回答(1个)
回答1:

create table xx_order_bak like xx_order;

alter table xx_order_bak add column `unit` int(10) DEFAULT 1;

INSERT INTO xx_order_bak(`id`, `create_date`, `modify_date`, `address`, `amount_paid`)
select * from xx_order;

rename table xx_order to xx_order_bak1;

rename table xx_order_bak to xx_order;