您的位置:首页 > 产品设计 > 产品经理

清除JBPM数据的SQL

2009-01-12 16:55 176 查看
JBPM的表使用了非常多的外键,通过外键实现数据的完整性约束。

当我们希望手工清除JBPM的数据时,这些外键就给我们带来了较大的困扰。

以下是根据经验整理出来的SQL,以备查(JBPM3.1.1版本):

delete

from jbpm_log

where token_ in(

select id_

from jbpm_token

where processinstance_ in(

select id_

from Jbpm_Processinstance

where id_ in(select processid from biz_table where title like 'condition %')

)

);

delete

from jbpm_taskactorpool

where taskinstance_ in(

select id_

from jbpm_taskinstance

where token_ in(

select id_

from jbpm_token

where processinstance_ in(

select id_

from Jbpm_Processinstance

where id_ in(select processid from biz_table where title like 'condition %')

)

)

);

delete

from jbpm_variableinstance

where processinstance_ in(

select id_

from Jbpm_Processinstance

where id_ in(select processid from biz_table where title like 'condition %')

);

delete

from jbpm_timer

where processinstance_ in(

select id_

from Jbpm_Processinstance

where id_ in(select processid from biz_table where title like 'condition %')

);

delete

from jbpm_taskinstance

where token_ in(

select id_

from jbpm_token

where processinstance_ in(

select id_

from Jbpm_Processinstance

where id_ in(select processid from biz_table where title like 'condition %')

)

);

delete

from jbpm_tokenvariablemap

where token_ in(

select id_

from jbpm_token

where processinstance_ in(

select id_

from Jbpm_Processinstance

where id_ in(select processid from biz_table where title like 'condition %')

)

);

alter table JBPM_PROCESSINSTANCE disable constraint FK_PROCIN_ROOTTKN;

delete

from jbpm_token

where processinstance_ in(

select id_

from Jbpm_Processinstance

where id_ in(select processid from biz_table where title like 'condition %')

);

delete

from jbpm_moduleinstance

where processinstance_ in(

select id_

from Jbpm_Processinstance

where id_ in(select processid from biz_table where title like 'condition %')

);

delete

from Jbpm_Processinstance

where id_ in(select processid from biz_table where title like 'condition %');

alter table JBPM_PROCESSINSTANCE enable constraint FK_PROCIN_ROOTTKN;

delete from biz_table where title like 'condition %';

commit;

根据实际情况将条件部分的SQL替换掉。这些SQL会彻底清除JBPM中的数据。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: