Backend/Spring+Boot
[SpringBatch] SpringBatch 이력테이블 초기화 스크립트
findmypiece
2022. 3. 29. 21:09
728x90
1개월 이전 이력 삭제.
자세한 설명은 생략한다.
DELIMITER $$
DELETE
FROM BATCH_STEP_EXECUTION_CONTEXT
WHERE STEP_EXECUTION_ID IN (
SELECT STEP_EXECUTION_ID
FROM BATCH_STEP_EXECUTION
where JOB_EXECUTION_ID in(
select JOB_EXECUTION_ID
from BATCH_JOB_EXECUTION
where CREATE_TIME < DATE_SUB(CURRENT_DATE(), INTERVAL 1 MONTH)
)
);
DELETE
FROM BATCH_STEP_EXECUTION
where JOB_EXECUTION_ID in(
select JOB_EXECUTION_ID
from BATCH_JOB_EXECUTION
where CREATE_TIME < DATE_SUB(CURRENT_DATE(), INTERVAL 1 MONTH)
);
DELETE
FROM BATCH_JOB_EXECUTION_CONTEXT
WHERE JOB_EXECUTION_ID in (
select JOB_EXECUTION_ID
from BATCH_JOB_EXECUTION
where CREATE_TIME < DATE_SUB(CURRENT_DATE(), INTERVAL 1 MONTH)
);
DELETE
FROM BATCH_JOB_EXECUTION_PARAMS
WHERE JOB_EXECUTION_ID in (
select JOB_EXECUTION_ID
from BATCH_JOB_EXECUTION
where CREATE_TIME < DATE_SUB(CURRENT_DATE(), INTERVAL 1 MONTH)
);
DELETE
FROM BATCH_JOB_EXECUTION
where CREATE_TIME < DATE_SUB(CURRENT_DATE(), INTERVAL 1 MONTH);
DELETE
FROM BATCH_JOB_INSTANCE
WHERE JOB_INSTANCE_ID IN (
select JOB_INSTANCE_ID
from BATCH_JOB_EXECUTION
where CREATE_TIME < DATE_SUB(CURRENT_DATE(), INTERVAL 1 MONTH)
);
DELIMITER ;
728x90