1.把需要的数据查询出来放进一个新表. select * into new_table from old_table2.然后truncate table old_table truncate table old_table3.从新表把数据插会旧表 insert into old_table select * from new_table4.删除新表 drop table new_table
如果表中的记录只有1亿条左右,则先把需要的数据查询出来放进一个新表(select * into new_table from old_table),这样的话可以避免产生很多的log(因为使用into);然后使用truncate table清空掉整个数据(在这个操作之前记得把需要的数据一定要放入刚才的新表中),这样效率很高,而且没有log,比直接drop要好很多。 以上意见,仅供参考!
truncate table tableName
truncate 你的表
最后把数据再倒回来
select * into new_table from old_table2.然后truncate table old_table
truncate table old_table3.从新表把数据插会旧表
insert into old_table select * from new_table4.删除新表
drop table new_table
首先将需要的数据查询出来然后在truncate
以上意见,仅供参考!
truncate 你的表
最后把数据再倒回来
把那一部分保留的先insert into 到临时表
truncate 你的表
最后把数据再倒回来