oracle 11g 建立 job
--建立一次執行的匿名塊任務,成功呼叫一次後job消失
BEGIN
DBMS_SCHEDULER.CREATE_JOB (
job_name => 'my_new_job2',
job_type => 'PLSQL_BLOCK',
job_action =>
'BEGIN
for i in 1 .. 5 loop
insert into t values (i);
end loop;
commit;
END;'
);
END;
--建立儲存過程代替匿名塊裡面的內容,對於資料量大的程式碼很方便
create or replace procedure p_insert_t
as
BEGIN
for i in 1 .. 5 loop
insert into t values (i);
end loop;
commit;
END;
BEGIN
DBMS_SCHEDULER.CREATE_JOB (
job_name => 'my_new_job2',
job_type => 'PLSQL_BLOCK',
job_action => 'BEGIN p_insert_t; END;'
);
END;
--檢視job的狀態
SELECT job_name, owner, program_name, program_owner, state, enabled
FROM dba_scheduler_jobs
WHERE owner NOT IN ('SYS', 'SYSTEM');
SELECT *
FROM dba_scheduler_jobs
WHERE owner NOT IN ('SYS', 'SYSTEM');
--執行job, enable job和run job兩種方式都可以呼叫job
--enable job之後自動執行job
BEGIN
DBMS_SCHEDULER.ENABLE ('my_new_job2');
END;
--run job
BEGIN
DBMS_SCHEDULER.RUN_JOB(
JOB_NAME => 'my_new_job2',
USE_CURRENT_SESSION => FALSE);
END;
--停止 job
BEGIN
DBMS_SCHEDULER.STOP_JOB('MY_NEW_JOB2');
END;
/
--刪除JOB
BEGIN
DBMS_SCHEDULER.DROP_JOB ('MY_NEW_JOB2');
END;
BEGIN
DBMS_SCHEDULER.CREATE_JOB (
job_name => 'my_new_job2',
job_type => 'PLSQL_BLOCK',
job_action =>
'BEGIN
for i in 1 .. 5 loop
insert into t values (i);
end loop;
commit;
END;'
);
END;
--建立儲存過程代替匿名塊裡面的內容,對於資料量大的程式碼很方便
create or replace procedure p_insert_t
as
BEGIN
for i in 1 .. 5 loop
insert into t values (i);
end loop;
commit;
END;
BEGIN
DBMS_SCHEDULER.CREATE_JOB (
job_name => 'my_new_job2',
job_type => 'PLSQL_BLOCK',
job_action => 'BEGIN p_insert_t; END;'
);
END;
--檢視job的狀態
SELECT job_name, owner, program_name, program_owner, state, enabled
FROM dba_scheduler_jobs
WHERE owner NOT IN ('SYS', 'SYSTEM');
SELECT *
FROM dba_scheduler_jobs
WHERE owner NOT IN ('SYS', 'SYSTEM');
--執行job, enable job和run job兩種方式都可以呼叫job
--enable job之後自動執行job
BEGIN
DBMS_SCHEDULER.ENABLE ('my_new_job2');
END;
--run job
BEGIN
DBMS_SCHEDULER.RUN_JOB(
JOB_NAME => 'my_new_job2',
USE_CURRENT_SESSION => FALSE);
END;
--停止 job
BEGIN
DBMS_SCHEDULER.STOP_JOB('MY_NEW_JOB2');
END;
/
--刪除JOB
BEGIN
DBMS_SCHEDULER.DROP_JOB ('MY_NEW_JOB2');
END;
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26506993/viewspace-1815050/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- oracle建立job並執行jobOracle
- ORACLE查詢JOB資訊及JOB建立Oracle
- Oracle JOB 建立例項Oracle
- oracle job的建立和刪除Oracle
- Oracle透過job定時建立表Oracle
- 通過oracle dbms_job建立tableOracle
- plsql建立jobSQL
- Oracle 11G EM建立Oracle
- oracle 11g dataguard 建立Oracle
- 【JOB】Oracle中JOB的建立方法以及一個細節的探究Oracle
- oracle建立定時任務之dbms_jobOracle
- ORACLE dbms_scheduler.create_job建立job作業遭遇PLS-00306Oracle
- Oracle:建立JOB定時執行儲存過程Oracle儲存過程
- 批量刪除dbms_job建立的job
- Oracle 11g 測試停庫對job的影響Oracle
- oracle jobOracle
- 建立Oracle 11g logical standbyOracle
- Oracle 11g 建立物化檢視Oracle
- DBMS_JOB.SUBMIT 建立job定時排程MIT
- Oracle中JOB的建立後不執行解決方法Oracle
- Oracle dbms_scheduler建立帶輸入引數的JOBOracle
- Oracle 11g報錯"ORA-12012: error on job ORACLE_OCM.MGMT_CONFIG_JOB_2_1"OracleError
- oracle job用法Oracle
- oracle job管理Oracle
- 手工建立ORACLE 11g 資料庫Oracle資料庫
- 使用DBMS_JOB和DBMS_SCHEDULER建立、管理job示例
- Oracle 11g 重新建立控制檔案Oracle
- oracle 11g建立基線詳細資訊Oracle
- Oracle 11g RAC Data Guard 物理standby 建立Oracle
- oracle 11G RAC 建立詳細過程Oracle
- 【JOB】Oracle JOB全面學習(DBMS_JOB和DBMS_SCHEDULER)Oracle
- oracle job管理(zt)Oracle
- oracle 定義jobOracle
- Oracle JOB的使用Oracle
- Oracle job備忘Oracle
- oracle job的用法Oracle
- oracle job 介紹Oracle
- oracle job 用法2Oracle