1、测试执行拆分工具,会发现会卡在某些表,记录好并在正式拆分前提前处理;
2、大表备份与处理;
3、正式执行拆分工具;
ps:拆分工具选择保留组织时只能选择实体组织,直接执行工具会导致部分不应该删除的虚体组织被删除;需要在选完保留组织后,收到在保留组织的表中插入全部要保留的组织id,然后再执行工具;
--temporg 以财务组织创建的临时表,里面储存的是FID一个字段
DROP TABLE temporg;
CREATE TABLE temporg AS SELECT
fid
FROM
T_ORG_BaseUnit
WHERE
flongnumber LIKE '%!01.02.02.01%'
OR flongnumber LIKE '%!01.02.02.02%'
OR flongnumber LIKE '%!01.02.02.03%'
OR flongnumber LIKE '%!01.02.02.04%'
OR flongnumber LIKE '%!01.02.03.03.01%'
OR flongnumber LIKE '%!01.02.03.03.02%'
OR flongnumber LIKE '%!01.02.02%'
OR flongnumber LIKE '%!01.02.03.03%';
--费用类型科目映射
DELETE FROM T_BC_ExpenseTypeSubjectMapping where FCompanyID in (select fid from temporg);
--费用类型核算项目映射
DELETE FROM T_BC_ExpenseTypeAsstActType where FCompanyID in (select fid from temporg);
--费用类型
Delete from T_BC_ExpenseTypeEntry where FParentId in (select fid from T_BC_ExpenseType where FCompanyID in (select fid from temporg));
Delete from T_BC_ExpenseType where FCompanyID in (select fid from temporg);
--业务类别
Delete from T_BC_OperationType where FCompanyID in (select fid from temporg);
--业务类别科目映射
DELETE FROM T_BC_OperationTypeSubject WHERE FCompanyID in (select fid from temporg);
--业务类别分录
DELETE FROM T_BC_OperationTypeCCEntry WHERE FcompanyId in (select fid from temporg);
--收款信息 没公司过滤全保留 T_BC_CollectionAccount
--员工额度表
Delete from T_BC_AccountLimit where FCompanyOrgUnitID in (select fid from temporg);
--额度控制 没公司过滤全保留 T_BC_BudgetControl
--代理报销
Delete from T_BC_ProxyReimburse where FCompanyID in (select fid from temporg);
--报销级别
Delete from T_BC_ReimburseLevel where FCompanyID in (select fid from temporg);
--额度设置
Delete from T_BC_REIMBURSELEVELSETTING where FCompanyOrgUnitID in (select fid from temporg);
--费用申请单
DELETE FROM T_BC_OtherExpenseBillEntry WHERE fbillid in(SELECT fid FROM T_BC_OtherExpenseBill WHERE FAPPLIERCOMPANYID in (select fid from temporg)); --费用申请单分录
DELETE FROM T_BC_OtherExpenseBill WHERE FAPPLIERCOMPANYID in (select fid from temporg);--费用申请单表头
--出差申请单
DELETE FROM T_BC_EvectionReqBillEntry where fbillid in(SELECT fid FROM T_BC_EvectionReqBill WHERE FAPPLIERCOMPANYID in (select fid from temporg));--出差申请单分录
DELETE FROM T_BC_EvectionReqBill WHERE FAPPLIERCOMPANYID in (select fid from temporg);--出差申请单表头
--费用报销单
DELETE FROM T_BC_BizABAR WHERE FParentID in (select fid from T_BC_BizAccountBill WHERE FAPPLIERCOMPANYID in (select fid from temporg)); --费用报销单记账记录表
DELETE from T_BC_BizABLCE where FParentID in (select fid from T_BC_BizAccountBill WHERE FAPPLIERCOMPANYID in (select fid from temporg)); --费用报销单借款核销表
DELETE FROM T_BC_BIZABRCE WHERE FParentID in (select fid from T_BC_BizAccountBill WHERE FAPPLIERCOMPANYID in (select fid from temporg)); --费用报销单申请核销表
DELETE FROM T_BC_BizAccountBCE WHERE FBillID in (select fid from T_BC_BizAccountBill WHERE FAPPLIERCOMPANYID in (select fid from temporg)); --费用报销单多收款人分录
DELETE FROM T_BC_BizAccountBillEntry WHERE fbillid in (select fid from T_BC_BizAccountBill WHERE FAPPLIERCOMPANYID in (select fid from temporg)); --费用报销单分录
DELETE from T_BC_BizAccountBill WHERE FAPPLIERCOMPANYID in (select fid from temporg);--费用报销单表头
--对公报销单
DELETE FROM T_BC_BizOABAR WHERE FParentID in (select fid from T_BC_BizAccountOutBill WHERE FAPPLIERCOMPANYID in (select fid from temporg)); --对公费用报销单记账记录表
DELETE from T_BC_BIZAOBLCE where FParentID in (select fid from T_BC_BizAccountOutBill WHERE FAPPLIERCOMPANYID in (select fid from temporg)); --对公费用报销单借款核销表
DELETE FROM T_BC_BIZAOBRCE WHERE FParentID in (select fid from T_BC_BizAccountOutBill WHERE FAPPLIERCOMPANYID in (select fid from temporg)); --对公费用报销单申请核销表
DELETE FROM T_BC_BIZAOBAE WHERE FBillID in (select fid from T_BC_BizAccountOutBill WHERE FAPPLIERCOMPANYID in (select fid from temporg)); --对公费用报销单多收款人分录
DELETE FROM T_BC_BizAccountOutBillEntry WHERE fbillid in (select fid from T_BC_BizAccountOutBill WHERE FAPPLIERCOMPANYID in (select fid from temporg)); --对公费用报销单分录
DELETE from T_BC_BizAccountOutBill WHERE FAPPLIERCOMPANYID in (select fid from temporg);-- 对公费用报销单表头
--差旅报销单
DELETE FROM T_BC_TravelABAR WHERE FParentID in (select fid from T_BC_TravelAccountBill WHERE FAPPLIERCOMPANYID in (select fid from temporg));--差旅报销单记账凭证记录表
DELETE FROM T_BC_TravelABLCE WHERE FParentID in (select fid from T_BC_TravelAccountBill WHERE FAPPLIERCOMPANYID in (select fid from temporg)); --差旅报销单借款核销表
DELETE FROM T_BC_TRAVELABRCE WHERE FParentID in (select fid from T_BC_TravelAccountBill WHERE FAPPLIERCOMPANYID in (select fid from temporg)); --差旅费报销单申请核销表
DELETE FROM T_BC_TravelAccountBCE WHERE FBillID in (select fid from T_BC_TravelAccountBill WHERE FAPPLIERCOMPANYID in (select fid from temporg)); --差旅费报销单多收款人分录
DELETE FROM T_BC_TravelAccountBillEntry WHERE fbillid in (select fid from T_BC_TravelAccountBill WHERE FAPPLIERCOMPANYID in (select fid from temporg));--差旅报销单分录
DELETE from T_BC_TravelAccountBill WHERE FAPPLIERCOMPANYID in (select fid from temporg); -- 差旅报销单表头
--物品采购报销单
DELETE FROM T_BC_DailyPABAR WHERE FParentID in (select fid from T_BC_DailyPurchaseAccountBill WHERE FAPPLIERCOMPANYID in (select fid from temporg));--差旅报销单记账凭证记录表
DELETE FROM T_BC_DAILYPABLCE WHERE FParentID in (select fid from T_BC_DailyPurchaseAccountBill WHERE FAPPLIERCOMPANYID in (select fid from temporg)); --物品采购报销单借款核销表
DELETE FROM T_BC_DAILYPABRCE WHERE FPARENTID in (select fid from T_BC_DailyPurchaseAccountBill WHERE FAPPLIERCOMPANYID in (select fid from temporg)); --物品采购报销单申请核销表
DELETE FROM T_BC_DailyPurchaseAccontEntry WHERE fbillid in (select fid from T_BC_DailyPurchaseAccountBill WHERE FAPPLIERCOMPANYID in (select fid from temporg));--物品采购报销单分录
DELETE from T_BC_DailyPurchaseAccountBill WHERE FAPPLIERCOMPANYID in (select fid from temporg); -- 物品采购报销单表头
--借款单
DELETE FROM T_BC_DailyLoanBAE where FBillID in (select fid from T_BC_DailyLoanBill WHERE FAPPLIERCOMPANYID in (select fid from temporg));--借款单多收款人分录
DELETE FROM T_BC_DailyLBRCE where FParentID in (select fid from T_BC_DailyLoanBill WHERE FAPPLIERCOMPANYID in (select fid from temporg));--借款单申请核销表
DELETE FROM T_BC_DailyLoanBillEntry WHERE fbillid in (select fid from T_BC_DailyLoanBill WHERE FAPPLIERCOMPANYID in (select fid from temporg)); --借款单分录
DELETE from T_BC_DailyLoanBill WHERE FAPPLIERCOMPANYID in (select fid from temporg); --借款单表头
--出差借款单
DELETE FROM T_BC_Evectionlbrce where FParentID in (select fid from T_BC_EvectionLoanBill WHERE FAPPLIERCOMPANYID in (select fid from temporg));--出差借款单申请核销表
DELETE FROM T_BC_EvectionLoanBillEntry WHERE FBillID in (select fid from T_BC_EvectionLoanBill WHERE FAPPLIERCOMPANYID in (select fid from temporg) ) ;--出差借款单分录
DELETE FROM T_BC_EvectionLoanBill WHERE FAPPLIERCOMPANYID in (select fid from temporg); -- 出差借款单表头
--还款单
DELETE FROM T_BC_RePaymentBillEntry WHERE FPARENTID in (select fid from T_BC_RePaymentBill WHERE FAPPLIERCOMPANYID in (select fid from temporg));--还款单分录
DELETE from T_BC_RePaymentBill WHERE FAPPLIERCOMPANYID in (select fid from temporg);--还款单表头
推荐阅读