清除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中的数据。
当我们希望手工清除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中的数据。
相关文章推荐
- SQL命令:清除数据缓存和执行计划缓存,查看执行计划
- 经常面试到的SQL题(查询重复数据和清除重复数据)
- SQL查询重复数据和清除重复数据
- SQLServer 工具箱v1.3(SQL脚本排序,日志清除,数据导入导出)附完整源代码
- 在MSDB中清除SQL Server 还原备份历史数据(Purging MSDB Backup and Restore History from SQL Server)
- sql 撤销索引、表已经数据库(drop)、清除表数据(truncate table)
- SQLServer 工具箱v1.3(SQL脚本排序,日志清除,数据导入导出)附完整源代码
- SQL查询重复数据和清除重复数据 整理
- 清除sql表中所有数据
- SQL查询重复数据和清除重复数据
- SQL查询重复数据和清除重复数据
- MSSQL中如何用SQL清除所有表的数据(downmoon)?
- MSSQL中如何用SQL清除所有表的数据(downmoon)
- SQLServer 工具箱v1.2(SQL脚本排序,日志清除,数据导入导出)附源代码
- mysql:sql truncate (清除表数据)
- SQL日常日志: 把一个表的数据插入到另一个表中,清除表里面的数据
- 清除字段数据的空格和回车SQL
- 【51CTO/BBS】SQL 语句中有没有清除控制台显示(返回)数据的命令啊??
- 在MSSQL中如何用SQL清除所有表的数据
- SQL查询重复数据和清除重复数据