作者:管理员  历史版本:1  最后编辑:Eddy  更新时间:2024-10-24 16:08

清除流程实例相关的数据SQL

清除扩展表数据

DELETE from ibps_bpm_approval;
DELETE from ibps_bpm_approval_his;
DELETE from ibps_bpm_exec;
DELETE from ibps_bpm_exec_seq;
DELETE from ibps_bpm_inst;
DELETE from ibps_bpm_inst_his;
DELETE from ibps_bpm_oper_log;
DELETE from ibps_bpm_oper_notify;
DELETE from ibps_bpm_oper_notify_recer;
DELETE from ibps_bpm_task_assign;
DELETE from ibps_bpm_task_change;
DELETE from ibps_bpm_task_change_assign;
DELETE from ibps_bpm_task_pendding;
DELETE from ibps_bpm_tasks;
DELETE from ibps_bpm_common_statment;

清除act本身

DELETE from act_ru_variable;
DELETE from act_ru_task;
DELETE from act_ru_identitylink;
DELETE from act_ru_execution;
DELETE from act_hi_actinst;
DELETE from act_hi_attachment;
DELETE from act_hi_identitylink;
DELETE from act_hi_procinst;
DELETE from act_hi_taskinst;
DELETE from act_hi_varinst;

以上清除的表数据,就是将已结束实例,正在运行的实例全部清除,即将流程定义设置没有启动流程的数据环境则按以上脚本执行!

若只是清除某个流程定义的实例数据,则需要根据流程实例ID找相关联的字段进行点对点删除!


例子:

${instId}是流程实例id,对应ibps_bpm_inst的ID_字段

DELETE from ibps_bpm_approval where PROC_INST_ID_=’${instId}’;
DELETE from ibps_bpm_approval_his where PROC_INST_ID_=’${instId}’;
DELETE from ibps_bpm_exec_seq where SRC_EXEC_ID_ in (select id_ from ibps_bpm_exec where PROC_INST_ID_=’${instId}’) or SRC_PROC_EXEC_ID_ in (select id_ from ibps_bpm_exec where PROC_INST_ID_=’${instId}’) or TARGET_EXEC_ID_ in (select id_ from ibps_bpm_exec where PROC_INST_ID_=’${instId}’);
DELETE from ibps_bpm_exec where PROC_INST_ID_=’${instId}’;
DELETE from ibps_bpm_oper_log where PROC_INST_ID_=’${instId}’;
DELETE from ibps_bpm_oper_notify_recer where NOTIFY_ID_ in (select ID_ from ibps_bpm_oper_notify ibon where ibon.PROC_INST_ID_ =’${instId}’);
DELETE from ibps_bpm_oper_notify where PROC_INST_ID_=’${instId}’;
DELETE from ibps_bpm_task_sign where INST_ID_=’${instId}’;
DELETE from ibps_bpm_task_supervise_rec where PROC_INST_ID_=’${instId}’;
DELETE from ibps_bpm_task_reminder_rec where PROC_INST_ID_=’${instId}’;
DELETE from ibps_bpm_task_pendding where PROC_INST_ID_=’${instId}’;
DELETE from ibps_bpm_task_change_assign where TASK_CHANGE_ID_ in (select ID_ from ibps_bpm_task_change ibtc where ibtc.PROC_INST_ID_ =’${instId}’);
DELETE from ibps_bpm_task_change where PROC_INST_ID_=’${instId}’;
DELETE from ibps_bpm_task_assign where PROC_INST_ID_=’${instId}’;
DELETE from ibps_bpm_tasks where PROC_INST_ID_=’${instId}’;
DELETE from ibps_bpm_bus_rel where PROC_INST_ID_=’${instId}’;
DELETE from ibps_bpm_inst where ID_=’${instId}’;
DELETE from ibps_bpm_inst_his where ID_=’${instId}’;

${bpmnInstId}是activiti原生流程实例id,对应ibps_bpm_inst的BPMN_INST_ID_字段

DELETE from act_ru_variable where PROC_INST_ID_=’${bpmnInstId}’;
DELETE from act_ru_task where PROC_INST_ID_=’${bpmnInstId}’;
DELETE from act_ru_identitylink where PROC_INST_ID_=’${bpmnInstId}’;
DELETE from act_ru_execution where PROC_INST_ID_=’${bpmnInstId}’;
DELETE from act_hi_actinst where PROC_INST_ID_=’${bpmnInstId}’;
DELETE from act_hi_identitylink where PROC_INST_ID_=’${bpmnInstId}’;
DELETE from act_hi_procinst where PROC_INST_ID_=’${bpmnInstId}’;
DELETE from act_hi_taskinst where PROC_INST_ID_=’${bpmnInstId}’;
DELETE from act_hi_varinst where PROC_INST_ID_=’${bpmnInstId}’;
DELETE from act_hi_attachment where PROC_INST_ID_=’${bpmnInstId}’;