-- 샘플 테이블 생성
CREATE TABLE CHECK_SCHEDULE
( INST_ID NUMBER, ACT_DATE DATE DEFAULT SYSDATE, ACT_DESC VARCHAR2(100)) ;
-- 샘플 프로시져 생성
CREATE OR REPLACE PROCEDURE DO_SCHEDULE_PROG
IS
V_SID NUMBER ;
V_INST NUMBER ;
BEGIN
SELECT INSTANCE_NUMBER INTO V_INST FROM V$INSTANCE ;
INSERT INTO CHECK_SCHEDULE ( INST_ID, ACT_DATE, ACT_DESC ) VALUES ( V_INST, SYSDATE, 'DO SCHEDULEING') ;
END ;
-- 스케줄 등록
EXEC DBMS_SCHEDULER.CREATE_SCHEDULE(schedule_name=>'CHK_SCHE',repeat_interval =>'FREQ=MINUTELY;INTERVAL=5')
-- 스케줄 확인
SELECT SCHEDULE_NAME, REPEAT_INTERVAL
FROM DBA_SCHEDULER_SCHEDULES
WHERE OWNER ='SP' AND SCHEDULE_NAME='CHK_SCHE';
-- 프로그램 등록
EXEC DBMS_SCHEDULER.CREATE_PROGRAM(PROGRAM_NAME=>'DO_SCHEDULE_PROGRAM',PROGRAM_TYPE=>'STORED_PROCEDURE',PROGRAM_ACTION=>'DO_SCHEDULE_PROG')
-- 프로그램 enable
EXEC DBMS_SCHEDULER.ENABLE('DO_SCHEDULE_PROGRAM')
-- 프로그램 확인
SELECT PROGRAM_NAME, PROGRAM_ACTION, ENABLED
FROM DBA_SCHEDULER_PROGRAMS
WHERE OWNER ='SP' AND PROGRAM_NAME='DO_SCHEDULE_PROGRAM';
-- 잡등록
EXEC DBMS_SCHEDULER.CREATE_JOB(JOB_NAME=>'CHK_SCHE_JOB' ,PROGRAM_NAME=>'DO_SCHEDULE_PROGRAM' ,SCHEDULE_NAME=>'CHK_SCHE' ,AUTO_DROP=>FALSE)
-- 잡 enable
EXEC DBMS_SCHEDULER.ENABLE('CHK_SCHE_JOB')
-- 잡 확인
SELECT JOB_NAME, PROGRAM_NAME, SCHEDULE_NAME, ENABLED
FROM DBA_SCHEDULER_JOBS
WHERE OWNER ='SP' AND JOB_NAME='CHK_SCHE_JOB';
-- 작업 결과 확인
SELECT LOG_DATE, ACTUAL_START_DATE, JOB_NAME, STATUS
FROM DBA_SCHEDULER_JOB_RUN_DETAILS WHERE JOB_NAME ='CHK_SCHE_JOB'
ORDER BY LOG_DATE DESC ;
-- 샘플 테이블 기록 확인
SELECT * FROM CHECK_SCHEDULE
ORDER BY ACT_DATE DESC ;
-- 스케줄 잡 instance_id 변경
exec dbms_scheduler.set_attribute(name =>'CHK_SCHE_JOB', attribute=>'INSTANCE_ID', value=>'2')
-- 스케줄 잡 intance_stickiness false 변경
exec dbms_scheduler.set_attribute(name =>'CHK_SCHE_JOB', attribute=>'INSTANCE_STICKINESS', value=>FALSE)
commit
'Oracle > etc' 카테고리의 다른 글
Function (0) | 2022.01.26 |
---|---|
CHECKPOINT NOT COMPLETE (0) | 2022.01.26 |
Redefinition (0) | 2022.01.26 |
ogg(Oracle Golden Gate) (0) | 2022.01.26 |
flashback (0) | 2022.01.26 |