db_device_data_bak_script.sql
1.1 KB
select count(*) from manufacture.device_running_record where device_running_record_id <=2000000
select count(*) from manufacture.device_collections where created_at <'2022-6-01 16:00:00'
--1.备份设备运行数据-按数量
-- 备份数据 2000000
select * into table manufacture.device_running_record_0_2000
from manufacture.device_running_record
where device_running_record_id <=2000000
-- 删除数据
delete from manufacture.device_running_record where device_running_record_id <=2000000;
-- 重建索引
reindex table manufacture.device_running_record;
--2.备份设备采集数据-按时间
-- 备份数据 2000000
select * into table manufacture.device_collections_history
from manufacture.device_collections
where created_at <'2022-6-01 16:00:00'
-- 删除数据
delete from manufacture.device_collections where created_at <'2022-6-01 16:00:00';
-- 重建索引
reindex table manufacture.device_collections;
--3.查看备份情况
select count(*) from manufacture.device_running_record_0_2000
select count(*) from manufacture.device_collections_history
select count(*) from manufacture.device_collections where created_at <'2022-6-01 16:00:00'