ORACLE 建立作業JOB例子,oracle作業job例子

來源:互聯網
上載者:User

ORACLE 建立作業JOB例子,oracle作業job例子
--1.plsql中學習job   
--學習job  
--建表  
create table test_job(para_date date);  
commit;  
  
insert into test_job values(sysdate);  
commit; 
 
select * from test_job;
  
--建立存貯過程   
create or replace procedure test_jobproce   as  
begin  
insert into test_job values(sysdate);  
end test_jobproce; 
  
--建立job  
--建立job後預設是執行的  
 
declare  test_job_really number;  
begin  
dbms_job.submit(test_job_really,'test_jobproce;',sysdate,'sysdate+1/1440');  
commit;  
end;  
  
---停止job  25是建立的job test_job_really  
begin  
dbms_job.broken(25,true);  
commit;  
end;  

--啟動job  
begin  
dbms_job.run(25);  
commit;  
end;  
 
--刪除job  
  
begin   
dbms_job.remove(25);  
commit;  
end;  
 
--查看執行結果  
select  * from test_job order by test_job.para_date desc;   

--查看job  
select * from sys.user_jobs   
  
--使用下面的SQL查詢是否JOB還在Running,前提是需要job執行時間不能過短  
  
select * from dba_jobs_running  

--除了submit參數外,其餘的幾個參數有:  
--運行job 
dbms_job.run(v_job);  
      
--停止一個job,裡面參數true也可是false,next_date(某一時刻停止)也可是sysdate(立刻停止)。  
dbms_job.broke(v_job,true,next_date); 
       
--刪除某個job  
dbms_job.remove(v_job);  
dbms_job.what(v_job,'sp_fact_charge_code;'); 
      
--修改某個job名 修改下一次已耗用時間  
 dbms_job.next_date(v_job,sysdate);  

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.