有些表时间长了,历史数据不用,可以将其备份到其它表中,以减小其大小

1
2
3
4
5
6
7
8

select * into [DCWLW].[dbo].cmd_log_bak210501
from [DCWLW].[dbo].cmd_log
where create_date < '2021-05-01';


delete from [DCWLW].[dbo].cmd_log
where create_date < '2021-05-01';

更好的方法还待探究。

最好是设置表能自动备份过期数据。