2.x双预防排查历史记录删除
2.x双预防排查历史记录删除
特此强调不要轻易去帮忙删除数据!!!!
1.首先连接数据库,使用navicat连接
2.查询你需要删除的多少数据
语句:select count(1) from wwyt_bp_investigate_task_his task left join wwyt_bp_investigate_record_his record on record.task_id = task.id left join wwyt_bp_investigate_record_item_his item on item.record_id = record.id left join wwyt_bp_investigate_task_assign_his assign on assign.task_id = task.id;
这个统计是和下面的语句结合查看的,下面语句有个limit 100000的可重复执行,具体看存量数据有多少
3.这个示例子是删除9月30号之前的所有历史记录
语句:UPDATE
wwyt_bp_investigate_task_summary
SET DELETE_FLAG = ‘1’ , update_by = -1
WHERE
CREATE_TIME <= ‘2024-10-01 00:00:00’;
UPDATE
wwyt_bp_investigate_task_summary_his
SET DELETE_FLAG = ‘1’ , update_by = -1
WHERE
CREATE_TIME <= ‘2024-10-01 00:00:00’;
UPDATE wwyt_bp_investigate_task task
LEFT JOIN wwyt_bp_investigate_record record ON record.task_id = task.id
LEFT JOIN wwyt_bp_investigate_record_item item ON item.record_id = record.id
LEFT JOIN wwyt_bp_investigate_task_assign assign ON assign.task_id = task.id
SET task.delete_flag = ‘1’,
record.delete_flag = ‘1’,
item.delete_flag = ‘1’,
assign.delete_flag = ‘1’,
task.update_by = -1,
record.update_by = -1,
item.update_by = -1,
assign.update_by = -1
where task.create_time <= ‘2024-10-01 00:00:00’;
UPDATE wwyt_bp_investigate_task_his task
LEFT JOIN wwyt_bp_investigate_record_his record ON record.task_id = task.id
LEFT JOIN wwyt_bp_investigate_record_item_his item ON item.record_id = record.id
LEFT JOIN wwyt_bp_investigate_task_assign_his assign ON assign.task_id = task.id
SET task.delete_flag = ‘1’,
record.delete_flag = ‘1’,
item.delete_flag = ‘1’,
assign.delete_flag = ‘1’,
task.update_by = -1,
record.update_by = -1,
item.update_by = -1,
assign.update_by = -1
where task.create_time <= ‘2024-10-01 00:00:00’ and task.delete_flag = ‘0’ limit 100000;
4.如果操作失误需要恢复请联系问题小组
恢复和删除语句:
– 删除按天汇总数据
UPDATE
wwyt_bp_investigate_task_summary
SET DELETE_FLAG = ‘1’ , update_by = -1
WHERE
CREATE_TIME <= ‘2024-10-01 00:00:00’;
– 恢复按天汇总数据
update wwyt_bp_investigate_task_summary set delete_flag = ‘0’ where CREATE_TIME <= ‘2024-10-01 00:00:00’ and delete_flag = 1 and update_by = -1;
– 删除按天汇总数据(历史)
UPDATE
wwyt_bp_investigate_task_summary_his
SET DELETE_FLAG = ‘1’ , update_by = -1
WHERE
CREATE_TIME <= ‘2024-10-01 00:00:00’;
– 恢复按天汇总数据(历史)
update wwyt_bp_investigate_task_summary_his set delete_flag = ‘0’ where CREATE_TIME <= ‘2024-10-01 00:00:00’ and delete_flag = ‘1’ and update_by = -1;
– 删除任务、记录、记录详情、任务分配人
UPDATE wwyt_bp_investigate_task task
LEFT JOIN wwyt_bp_investigate_record record ON record.task_id = task.id
LEFT JOIN wwyt_bp_investigate_record_item item ON item.record_id = record.id
LEFT JOIN wwyt_bp_investigate_task_assign assign ON assign.task_id = task.id
SET task.delete_flag = ‘1’,
record.delete_flag = ‘1’,
item.delete_flag = ‘1’,
assign.delete_flag = ‘1’,
task.update_by = -1,
record.update_by = -1,
item.update_by = -1,
assign.update_by = -1
where task.create_time <= ‘2024-10-01 00:00:00’;
– 恢复任务、记录、记录详情、任务分配人
UPDATE wwyt_bp_investigate_task task
LEFT JOIN wwyt_bp_investigate_record record ON record.task_id = task.id
LEFT JOIN wwyt_bp_investigate_record_item item ON item.record_id = record.id
LEFT JOIN wwyt_bp_investigate_task_assign assign ON assign.task_id = task.id
SET task.delete_flag = ‘0’,
record.delete_flag = ‘0’,
item.delete_flag = ‘0’,
assign.delete_flag = ‘0’
where task.create_time <= ‘2024-10-01 00:00:00’ and task.delete_flag = ‘1’ and update_by = -1;
– 删除任务、记录、记录详情、任务分配人(历史)
UPDATE wwyt_bp_investigate_task_his task
LEFT JOIN wwyt_bp_investigate_record_his record ON record.task_id = task.id
LEFT JOIN wwyt_bp_investigate_record_item_his item ON item.record_id = record.id
LEFT JOIN wwyt_bp_investigate_task_assign_his assign ON assign.task_id = task.id
SET task.delete_flag = ‘1’,
record.delete_flag = ‘1’,
item.delete_flag = ‘1’,
assign.delete_flag = ‘1’,
task.update_by = -1,
record.update_by = -1,
item.update_by = -1,
assign.update_by = -1
where task.create_time <= ‘2024-10-01 00:00:00’ and task.delete_flag = ‘0’ limit 100000;
– 恢复任务、记录、记录详情、任务分配人(历史)
UPDATE wwyt_bp_investigate_task_his task
LEFT JOIN wwyt_bp_investigate_record_his record ON record.task_id = task.id
LEFT JOIN wwyt_bp_investigate_record_item_his item ON item.record_id = record.id
LEFT JOIN wwyt_bp_investigate_task_assign_his assign ON assign.task_id = task.id
SET task.delete_flag = ‘0’,
record.delete_flag = ‘0’,
item.delete_flag = ‘0’,
assign.delete_flag = ‘0’
where task.create_time <= ‘2024-10-01 00:00:00’ and task.delete_flag = ‘1’ and update_by = -1 limit 100000;
转载请注明作者和出处,并添加本页链接。
原文链接:
//svn.seekcy.com:33382/721