Home > Database > Mysql Tutorial > 定时执行Oracle作业任务

定时执行Oracle作业任务

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 17:26:04
Original
1082 people have browsed it

创建一个Oracle数据表,并创建一个过程,使一分钟运行该过程一次。

创建一个Oracle数据表,并创建一个过程,使一分钟运行该过程一次。

1)创建表。

SQL> create table test (mydate date);

Table created.

(2)创建一个自定义过程。

SQL> create or replace procedure proc_test as
  2  BEGIN
  3  insert into test values(sysdate);
  4  END;
  5  /

Procedure created.

(3)创建JOB。

SQL> var job number
SQL> var job number;

--每天1440分钟,一分钟运行test过程一次
SQL> begin
  2  dbms_job.submit(:job,'proc_test;',sysdate,'sysdate+1/1440');
  3  END;
  4  /

PL/SQL procedure successfully completed.

(4)运行JOB。

SQL> BEGIN
  2  dbms_job.run(:job);
  3  END;
  4  /

PL/SQL procedure successfully completed.

(5)查询下看看是否定时执行了JOB

SQL> SELECT to_char(mydate,'yyyy/mm/dd hh24:mi:ss')insertedtime FROM test;

INSERTEDTIME
-------------------
2013/01/24 04:40:10
2013/01/24 04:42:12
2013/01/24 04:43:17
2013/01/24 04:41:11
2013/01/24 04:39:08


(6)删除JOB。

SQL> begin
  2  dbms_job.remove(:job);
  3  END;
  4  /

PL/SQL procedure successfully completed.

linux

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template