整体思路:
1.备份现有系统数据,提供一个可以查询历史的入口(可以查询2015年6月份以前的所有OA产生的流程)
2.删除生产环境中2015年6月份以前的流程
为避免影响考勤,暂定在本月考勤定稿后实施
实施方案:
思路:
①创建和flow_run_data、flow_run、flow_run_prcs、flow_run_log表结构一致的表
②把需要清理的历史数据插入刚创建的备份表中
③删除正式表中的数据
④将流水号小于1552669的流程,并且发起时间晚于2016-6月后发起的流程,补充回来
操作:
1.前端oa web暂停访问服务,备份TD_OA数据库
# /opt/lampp/lampp stopmysql# cd /opt/lampp/var/mysql
# cp -r TD_OA TD_OA20160110
# /opt/lampp/lampp startmysql
2.依次执行以下SQL语句:
首先找出流水号小于1552669即将被删除的流程,但流程发起时间再2015年6月以后的流程,记录下来备用
select * from FLOW_RUN where run_id<=1552669 and BEGIN_TIME >= '2015-06-01 00:00:00'
//对FLOW_RUN的操作
CREATE TABLE FLOW_RUN20160110 LIKE FLOW_RUN;
INSERT INTO FLOW_RUN20160110 SELECT * FROM FLOW_RUN WHERE RUN_ID < '1552669';
DELETE FROM FLOW_RUN WHERE RUN_ID < '1552669';
INSERT INTO FLOW_RUN select * from FLOW_RUN20160110 where run_id in('584490','621983','703990','733445','734642','734644','749954','764080','780194','839734','842274','842278','892757','932299','943126','944519','960193','962908','969219','970406','970408','976232','979118','982751','992712','994829','994830','999550','1002805','1002899','1007474','1025116','1027857','1030068','1032745','1032902','1033768','1038664','1039657','1040968','1040972','1048023','1048016','1054885','1066457','1070039','1071353','1072081','1075418','1076231','1076697','1083951','1083958','1085104','1091354','1108510','1112252','1114173','1114176','1140968','1142448','1146718','1208277','1208682','1216832','1228601','1235767','1240570','1263727','1268715','1268758','1269839','1272948','1290858','1295721','1295753','1298645','1298741','1303259','1303738','1307887','1312995','1317068','1317307','1325178','1325912','1329457','1329851','1329981','1329983','1330877','1332508','1332647','1332751','1332891','1334072','1335860','1337215','1338074','1340149','1342051','1343507','1346642','1346946','1348131','1348132','1348158','1348162','1356573','1373057','1376649','1378173','1380292','1380330','1380845','1381094','1383155','1383471','1383473','1386240','1387288','1387779','1388137','1388138','1389978','1390044','1391211','1391327','1391328','1392363','1392737','1393690','1395162','1395271','1396384','1397462','1398062','1399178','1399419','1401378','1401826','1402605','1403587','1403882','1403913','1404044','1404046','1404052','1404054','1404773','1406228','1406987','1409131','1410499','1410585','1411032','1411042','1411282','1411305','1411309','1411312','1411793','1413874','1413876','1413879','1414104','1414870','1414871','1414875','1415664','1416085','1416090','1416221','1417097','1418177','1418494','1418495','1418990','1420509','1420587','1421184','1422028','1422390','1422640','1422840','1423347','1424677','1425187','1425281','1425566','1425722','1429117','1429135','1429922','1432571','1432776','1433991','1434899','1436004','1436849','1437395','1438758','1438800','1438803','1439295','1439383','1442837','1443094','1444598','1446595','1451527','1453569','1454404','1458178','1460047','1460248','1460249','1460449','1507804','1463741','1463871','1466738','1467790','1468011','1468015','1468016','1468930','1469419','1470052','1471155','1471815','1471899','1472586','1472594','1473151','1473213','1473214','1473220','1473226','1475437','1477486','1477571','1478596','1479365','1482224','1482669','1486315','1486387','1488028','1488638','1489844','1494423','1498233','1498465','1499322','1500198','1501502','1501639','1502556','1503971','1504104','1504647','1505152','1505230','1506171','1506837','1508201','1508812','1509057','1509058','1509192','1509665','1509667','1509895','1511559','1512804','1513202','1513323','1513608','1514809','1515444','1516612','1516817','1517208','1517253','1518300','1518877','1519663','1519768','1519831','1519832','1519833','1520211','1520216','1520217','1520807','1520891','1520893','1520901','1521384','1521385','1521386','1521387','1521388','1521389','1521390','1521820','1521901','1522096','1523222','1525120','1526357','1526509','1526700','1527649','1531102','1531297','1531299','1531332','1531337','1531338','1531591','1531687','1531913','1532700','1532701','1533501','1533831','1533932','1534445','1535170','1536261','1536996','1537319','1537806','1538574','1539426','1539455','1539585','1540010','1540457','1540458','1540461','1540510','1540513','1540537','1540548','1540553','1540602','1540852','1541183','1541286','1541735','1542414','1542529','1542530','1542605','1542673','1542793','1543892','1544197','1544495','1544638','1544707','1544710','1544934','1545097','1545575','1545731','1545732','1545886','1546157','1546940','1547013','1547014','1547312','1547320','1547700','1547908','1548047','1548612','1548780','1548782','1548788','1549280','1549419','1549422','1549467','1549492','1549499','1549589','1549592','1549594','1549966','1549967','1550045','1550073','1550271','1550292','1550499','1551504','1551779','1552669')
//对FLOW_RUN_DATA的操作
CREATE TABLE FLOW_RUN_DATA20160110 LIKE FLOW_RUN_DATA;
INSERT FLOW_RUN_DATA20160110 SELECT * FROM FLOW_RUN_DATA WHERE RUN_ID < '1552669'
DELETE FROM FLOW_RUN_DATA WHERE RUN_ID < '1552669';
INSERT INTO FLOW_RUN_DATA select * from FLOW_RUN_DATA20160110 where run_id in('584490','621983','703990','733445','734642','734644','749954','764080','780194','839734','842274','842278','892757','932299','943126','944519','960193','962908','969219','970406','970408','976232','979118','982751','992712','994829','994830','999550','1002805','1002899','1007474','1025116','1027857','1030068','1032745','1032902','1033768','1038664','1039657','1040968','1040972','1048023','1048016','1054885','1066457','1070039','1071353','1072081','1075418','1076231','1076697','1083951','1083958','1085104','1091354','1108510','1112252','1114173','1114176','1140968','1142448','1146718','1208277','1208682','1216832','1228601','1235767','1240570','1263727','1268715','1268758','1269839','1272948','1290858','1295721','1295753','1298645','1298741','1303259','1303738','1307887','1312995','1317068','1317307','1325178','1325912','1329457','1329851','1329981','1329983','1330877','1332508','1332647','1332751','1332891','1334072','1335860','1337215','1338074','1340149','1342051','1343507','1346642','1346946','1348131','1348132','1348158','1348162','1356573','1373057','1376649','1378173','1380292','1380330','1380845','1381094','1383155','1383471','1383473','1386240','1387288','1387779','1388137','1388138','1389978','1390044','1391211','1391327','1391328','1392363','1392737','1393690','1395162','1395271','1396384','1397462','1398062','1399178','1399419','1401378','1401826','1402605','1403587','1403882','1403913','1404044','1404046','1404052','1404054','1404773','1406228','1406987','1409131','1410499','1410585','1411032','1411042','1411282','1411305','1411309','1411312','1411793','1413874','1413876','1413879','1414104','1414870','1414871','1414875','1415664','1416085','1416090','1416221','1417097','1418177','1418494','1418495','1418990','1420509','1420587','1421184','1422028','1422390','1422640','1422840','1423347','1424677','1425187','1425281','1425566','1425722','1429117','1429135','1429922','1432571','1432776','1433991','1434899','1436004','1436849','1437395','1438758','1438800','1438803','1439295','1439383','1442837','1443094','1444598','1446595','1451527','1453569','1454404','1458178','1460047','1460248','1460249','1460449','1507804','1463741','1463871','1466738','1467790','1468011','1468015','1468016','1468930','1469419','1470052','1471155','1471815','1471899','1472586','1472594','1473151','1473213','1473214','1473220','1473226','1475437','1477486','1477571','1478596','1479365','1482224','1482669','1486315','1486387','1488028','1488638','1489844','1494423','1498233','1498465','1499322','1500198','1501502','1501639','1502556','1503971','1504104','1504647','1505152','1505230','1506171','1506837','1508201','1508812','1509057','1509058','1509192','1509665','1509667','1509895','1511559','1512804','1513202','1513323','1513608','1514809','1515444','1516612','1516817','1517208','1517253','1518300','1518877','1519663','1519768','1519831','1519832','1519833','1520211','1520216','1520217','1520807','1520891','1520893','1520901','1521384','1521385','1521386','1521387','1521388','1521389','1521390','1521820','1521901','1522096','1523222','1525120','1526357','1526509','1526700','1527649','1531102','1531297','1531299','1531332','1531337','1531338','1531591','1531687','1531913','1532700','1532701','1533501','1533831','1533932','1534445','1535170','1536261','1536996','1537319','1537806','1538574','1539426','1539455','1539585','1540010','1540457','1540458','1540461','1540510','1540513','1540537','1540548','1540553','1540602','1540852','1541183','1541286','1541735','1542414','1542529','1542530','1542605','1542673','1542793','1543892','1544197','1544495','1544638','1544707','1544710','1544934','1545097','1545575','1545731','1545732','1545886','1546157','1546940','1547013','1547014','1547312','1547320','1547700','1547908','1548047','1548612','1548780','1548782','1548788','1549280','1549419','1549422','1549467','1549492','1549499','1549589','1549592','1549594','1549966','1549967','1550045','1550073','1550271','1550292','1550499','1551504','1551779','1552669')
//对FLOW_RUN_PRCS操作
CREATE TABLE FLOW_RUN_PRCS20160110 LIKE FLOW_RUN_PRCS;
INSERT INTO FLOW_RUN_PRCS20160110 SELECT * FROM FLOW_RUN_PRCS WHERE RUN_ID < '1552669'
DELETE FROM FLOW_RUN_PRCS WHERE RUN_ID < '1552669';
INSERT INTO FLOW_RUN_PRCS select * from FLOW_RUN_PRCS20160110 where run_id in('584490','621983','703990','733445','734642','734644','749954','764080','780194','839734','842274','842278','892757','932299','943126','944519','960193','962908','969219','970406','970408','976232','979118','982751','992712','994829','994830','999550','1002805','1002899','1007474','1025116','1027857','1030068','1032745','1032902','1033768','1038664','1039657','1040968','1040972','1048023','1048016','1054885','1066457','1070039','1071353','1072081','1075418','1076231','1076697','1083951','1083958','1085104','1091354','1108510','1112252','1114173','1114176','1140968','1142448','1146718','1208277','1208682','1216832','1228601','1235767','1240570','1263727','1268715','1268758','1269839','1272948','1290858','1295721','1295753','1298645','1298741','1303259','1303738','1307887','1312995','1317068','1317307','1325178','1325912','1329457','1329851','1329981','1329983','1330877','1332508','1332647','1332751','1332891','1334072','1335860','1337215','1338074','1340149','1342051','1343507','1346642','1346946','1348131','1348132','1348158','1348162','1356573','1373057','1376649','1378173','1380292','1380330','1380845','1381094','1383155','1383471','1383473','1386240','1387288','1387779','1388137','1388138','1389978','1390044','1391211','1391327','1391328','1392363','1392737','1393690','1395162','1395271','1396384','1397462','1398062','1399178','1399419','1401378','1401826','1402605','1403587','1403882','1403913','1404044','1404046','1404052','1404054','1404773','1406228','1406987','1409131','1410499','1410585','1411032','1411042','1411282','1411305','1411309','1411312','1411793','1413874','1413876','1413879','1414104','1414870','1414871','1414875','1415664','1416085','1416090','1416221','1417097','1418177','1418494','1418495','1418990','1420509','1420587','1421184','1422028','1422390','1422640','1422840','1423347','1424677','1425187','1425281','1425566','1425722','1429117','1429135','1429922','1432571','1432776','1433991','1434899','1436004','1436849','1437395','1438758','1438800','1438803','1439295','1439383','1442837','1443094','1444598','1446595','1451527','1453569','1454404','1458178','1460047','1460248','1460249','1460449','1507804','1463741','1463871','1466738','1467790','1468011','1468015','1468016','1468930','1469419','1470052','1471155','1471815','1471899','1472586','1472594','1473151','1473213','1473214','1473220','1473226','1475437','1477486','1477571','1478596','1479365','1482224','1482669','1486315','1486387','1488028','1488638','1489844','1494423','1498233','1498465','1499322','1500198','1501502','1501639','1502556','1503971','1504104','1504647','1505152','1505230','1506171','1506837','1508201','1508812','1509057','1509058','1509192','1509665','1509667','1509895','1511559','1512804','1513202','1513323','1513608','1514809','1515444','1516612','1516817','1517208','1517253','1518300','1518877','1519663','1519768','1519831','1519832','1519833','1520211','1520216','1520217','1520807','1520891','1520893','1520901','1521384','1521385','1521386','1521387','1521388','1521389','1521390','1521820','1521901','1522096','1523222','1525120','1526357','1526509','1526700','1527649','1531102','1531297','1531299','1531332','1531337','1531338','1531591','1531687','1531913','1532700','1532701','1533501','1533831','1533932','1534445','1535170','1536261','1536996','1537319','1537806','1538574','1539426','1539455','1539585','1540010','1540457','1540458','1540461','1540510','1540513','1540537','1540548','1540553','1540602','1540852','1541183','1541286','1541735','1542414','1542529','1542530','1542605','1542673','1542793','1543892','1544197','1544495','1544638','1544707','1544710','1544934','1545097','1545575','1545731','1545732','1545886','1546157','1546940','1547013','1547014','1547312','1547320','1547700','1547908','1548047','1548612','1548780','1548782','1548788','1549280','1549419','1549422','1549467','1549492','1549499','1549589','1549592','1549594','1549966','1549967','1550045','1550073','1550271','1550292','1550499','1551504','1551779','1552669')
//FLOW_RUN_LOG操作
CREATE TABLE FLOW_RUN_LOG20160110 LIKE FLOW_RUN_LOG;
INSERT INTO FLOW_RUN_LOG20160110 SELECT * FROM FLOW_RUN_LOG WHERE RUN_ID < '1552669'
DELETE FROM FLOW_RUN_LOG WHERE RUN_ID < '1552669';
INSERT INTO FLOW_RUN_LOG select * from FLOW_RUN_LOG20160110 where run_id in('584490','621983','703990','733445','734642','734644','749954','764080','780194','839734','842274','842278','892757','932299','943126','944519','960193','962908','969219','970406','970408','976232','979118','982751','992712','994829','994830','999550','1002805','1002899','1007474','1025116','1027857','1030068','1032745','1032902','1033768','1038664','1039657','1040968','1040972','1048023','1048016','1054885','1066457','1070039','1071353','1072081','1075418','1076231','1076697','1083951','1083958','1085104','1091354','1108510','1112252','1114173','1114176','1140968','1142448','1146718','1208277','1208682','1216832','1228601','1235767','1240570','1263727','1268715','1268758','1269839','1272948','1290858','1295721','1295753','1298645','1298741','1303259','1303738','1307887','1312995','1317068','1317307','1325178','1325912','1329457','1329851','1329981','1329983','1330877','1332508','1332647','1332751','1332891','1334072','1335860','1337215','1338074','1340149','1342051','1343507','1346642','1346946','1348131','1348132','1348158','1348162','1356573','1373057','1376649','1378173','1380292','1380330','1380845','1381094','1383155','1383471','1383473','1386240','1387288','1387779','1388137','1388138','1389978','1390044','1391211','1391327','1391328','1392363','1392737','1393690','1395162','1395271','1396384','1397462','1398062','1399178','1399419','1401378','1401826','1402605','1403587','1403882','1403913','1404044','1404046','1404052','1404054','1404773','1406228','1406987','1409131','1410499','1410585','1411032','1411042','1411282','1411305','1411309','1411312','1411793','1413874','1413876','1413879','1414104','1414870','1414871','1414875','1415664','1416085','1416090','1416221','1417097','1418177','1418494','1418495','1418990','1420509','1420587','1421184','1422028','1422390','1422640','1422840','1423347','1424677','1425187','1425281','1425566','1425722','1429117','1429135','1429922','1432571','1432776','1433991','1434899','1436004','1436849','1437395','1438758','1438800','1438803','1439295','1439383','1442837','1443094','1444598','1446595','1451527','1453569','1454404','1458178','1460047','1460248','1460249','1460449','1507804','1463741','1463871','1466738','1467790','1468011','1468015','1468016','1468930','1469419','1470052','1471155','1471815','1471899','1472586','1472594','1473151','1473213','1473214','1473220','1473226','1475437','1477486','1477571','1478596','1479365','1482224','1482669','1486315','1486387','1488028','1488638','1489844','1494423','1498233','1498465','1499322','1500198','1501502','1501639','1502556','1503971','1504104','1504647','1505152','1505230','1506171','1506837','1508201','1508812','1509057','1509058','1509192','1509665','1509667','1509895','1511559','1512804','1513202','1513323','1513608','1514809','1515444','1516612','1516817','1517208','1517253','1518300','1518877','1519663','1519768','1519831','1519832','1519833','1520211','1520216','1520217','1520807','1520891','1520893','1520901','1521384','1521385','1521386','1521387','1521388','1521389','1521390','1521820','1521901','1522096','1523222','1525120','1526357','1526509','1526700','1527649','1531102','1531297','1531299','1531332','1531337','1531338','1531591','1531687','1531913','1532700','1532701','1533501','1533831','1533932','1534445','1535170','1536261','1536996','1537319','1537806','1538574','1539426','1539455','1539585','1540010','1540457','1540458','1540461','1540510','1540513','1540537','1540548','1540553','1540602','1540852','1541183','1541286','1541735','1542414','1542529','1542530','1542605','1542673','1542793','1543892','1544197','1544495','1544638','1544707','1544710','1544934','1545097','1545575','1545731','1545732','1545886','1546157','1546940','1547013','1547014','1547312','1547320','1547700','1547908','1548047','1548612','1548780','1548782','1548788','1549280','1549419','1549422','1549467','1549492','1549499','1549589','1549592','1549594','1549966','1549967','1550045','1550073','1550271','1550292','1550499','1551504','1551779','1552669')
验证数据量是否和预估的相同
select count(run_id) from FLOW_RUN //327503
select count(run_id) from FLOW_RUN_DATA //13419201
select count(run_id) from FLOW_RUN_PRCS //1082718