整体思路:

1.备份现有系统数据,提供一个可以查询历史的入口(可以查询2015年6月份以前的所有OA产生的流程)

2.删除生产环境中2015年6月份以前的流程

为避免影响考勤,暂定在本月考勤定稿后实施

实施方案:

数据量大的信息主要是流程,主要存放在flow_run流程主表,flow_run_data流程数据表,flow_run_prcs流程审批信息,flow_run_log流程日志表中,清理

思路:

①创建和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

3、在门户首页提供可查询历史的链接,并将备份的数据库拷贝到链接后台数据库中

4、验证通过后恢复首页访问

通达OA数据库优化方案之_历史数据清理的更多相关文章

  1. centos6.5环境通达OA数据库mysql5.0.67升级至mysql5.5.48方案

    centos6.5环境通达OA数据库mysql5.0.67升级至mysql5.5.42方案 整体方案: 环境准备,在备用服务器安装mysql5.5数据库 1.停用生产环境的应用访问 直接修改web的访 ...

  2. 数据库SQL优化大总结之 百万级数据库优化方案(转载)

    网上关于SQL优化的教程很多,但是比较杂乱.近日有空整理了一下,写出来跟大家分享一下,其中有错误和不足的地方,还请大家纠正补充. 这篇文章我花费了大量的时间查找资料.修改.排版,希望大家阅读之后,感觉 ...

  3. mysql 百万级数据库优化方案

    https://blog.csdn.net/Kaitiren/article/details/80307828 一.百万级数据库优化方案 1.对查询进行优化,要尽量避免全表扫描,首先应考虑在 wher ...

  4. 数据库SQL优化百万级数据库优化方案

    1.对查询进行优化,要尽量避免全表扫描,首先应考虑在 where 及 order by 涉及的列上建立索引. 2.应尽量避免在 where 子句中对字段进行 null 值判断,否则将导致引擎放弃使用索 ...

  5. 数据库sql优化总结之1-百万级数据库优化方案+案例分析

    项目背景 有三张百万级数据表 知识点表(ex_subject_point)9,316条数据 试题表(ex_question_junior)2,159,519条数据 有45个字段 知识点试题关系表(ex ...

  6. 修改通达oa数据库root密码

    第一步: 打开通达oamysql远程网页地址:如http://127.0.0.1/mysql,点击修改密码功能按钮,根据提示修改,不要生成加密密码,执行即可! 第二步:修改service.php文件的 ...

  7. 数据库sql优化总结之2-百万级数据库优化方案+案例分析

    项目背景 有三张百万级数据表 知识点表(ex_subject_point)9,316条数据 试题表(ex_question_junior)2,159,519条数据 有45个字段 知识点试题关系表(ex ...

  8. 浅谈数据库优化方案--表和SQL

    1.数据类型的选择 1.字段最好设置为非空.若字段为char(8),即便是NULL也会现有8个字符的空间. 2.尽量使用数字型字段,若只含数值信息的字段尽量不要设计为字符型,这会降低查询和连接的性能, ...

  9. 数据库SQL优化大总结之 百万级数据库优化方案

    1.对查询进行优化,要尽量避免全表扫描,首先应考虑在 where 及 order by 涉及的列上建立索引. 2.应尽量避免在 where 子句中对字段进行 null 值判断,否则将导致引擎放弃使用索 ...

随机推荐

  1. 洛谷P1012 拼数 string

    又是大水题... 这一题过水,令人无法接受...... 但是如果我们不知道string的一个神奇的性质的话,就会很难受. 我一开始手写 < 号,但是发现如果 string a 的前一部分恰好是 ...

  2. Web应用:当文件超过100KB,无法上传,有种原因你想象不到

    今天下午2点多,突然发现凡是文件超过100KB的,在上传的时候都会卡住,但低于100KB的文件可以上传成功. 服务器端使用的是asp无组件上传,为什么突然出现这种问题呢? 我们知道,IIS默认上传限制 ...

  3. Sublime Text3—常用插件Emmet

    摘要 安装请看上一篇Sublime Text-安装,和sublime自带快捷键一起用,写html简直快的飞起. 下面整理的是常用的,完整的可看emmet官方文档. 一.生成标签 1.快速生成文档结构 ...

  4. csp20151203画图 解题报告和易错地方

    Solution: dfs 对于dfs: //遇到map[u][v]==c,则不用再搜    //因为通过(u,v)到达的其它点(p,q),    //之前从(u,v)开始肯定能到达(p,q),(p, ...

  5. mapping生成sam文件时出现[mem_sam_pe] paired reads have different names错误

    用以下命令修复: bbrename.sh in1=read1.fq in2=read2.fq out1=renamed1.fq out2=renamed2.fq bbrename.sh 下载地址网上自 ...

  6. get方式传值中文乱码

    问题描述: 本机可以,服务器乱码: 解决方案: 我采用了第三条,改server.xml配置 方法一: get方式提交的参数编码,只支持iso8859-1编码.因此,如果里面有中文.在后台就需要转换编码 ...

  7. vs2010中使用 git

    在没有使用git之前的,我很苦恼.因为我的代码有时在办公室做,有时也带回家做.做了一些时间,放在哪,要用的时间就不知道家里的还是办公室的是新版本了.甚至出现了旧版本把新版本覆盖的乌龙事情.有了git只 ...

  8. 什么是 Spring?

    感想: 我在写这个东西的时候看了不同的视频,和不同的书,关于对于spring的讲解,感觉黑马的培训视频,是讲的更加的让人容易理解. 这段时间因为各种的事情,没有写过博客了,曾经做的笔记有的在有道云笔记 ...

  9. javascript 值类型和引用类型

    值类型 1. 值类型:string/number/boolean/undefined: 2. 存储:值类型的数据,存储的是数据本身的变量: 3. 赋值:直接将存储的数据复制一份进行赋值,两份数据在内存 ...

  10. Hadoop记录-hadoop介绍

    1.hadoop是什么? Hadoop 是Apache基金会下一个开源的大数据分布式计算平台,它以分布式文件系统HDFS和MapReduce算法为核心,为用户提供了系统底层细节透明的分布式基础架构. ...