`
whiskyzhu
  • 浏览: 7667 次
  • 性别: Icon_minigender_1
  • 来自: 南京
最近访客 更多访客>>
文章分类
社区版块
存档分类
最新评论

TEST ORACLE JOB

阅读更多

--创建表空间,系统用户建立 
create tablespace tstest 
datafile 'D:\oraclexe\oradata\XE\tstest01.dbf' 
size 100m 
autoextend on 
next 50m 
maxsize 1000m; 
--删除表空间 
DROP tablespace tstest INCLUDING CONTENTS AND DATAFILES; 

--创建用户 
create user test identified by test default tablespace tstest temporary tablespace TEMP; 
grant connect,dba,resource to test ; 
--删除用户 
drop user test cascade; 

--创建表 
CREATE TABLE test 
( 
id VARCHAR2(100) PRIMARY KEY, 
name VARCHAR2(100), 
age VARCHAR2(100), 
sex VARCHAR2(100) 
); 

--创建一个存储过程用来删除表中过期数据 
CREATE OR REPLACE PROCEDURE MYPROC 
IS 
BEGIN 
insert into test(id,name,age,sex) values (sysdate,'tom','12','boy'); 
END; 
/ 

--创建JOB
variable job1 number;
 begin
 dbms_job.submit(:job1,'MYPROC;',sysdate,'sysdate+1/1440');
 commit;
 end;
/ 

--创建job,每天1440分钟,即一分钟运行test过程一次
variable job1 number;
begin
 dbms_job.submit(:job1,'INSERT_EXPIRY_DATAS;',sysdate,'sysdate+1/1440');
 end;
/

--运行job
begin
 dbms_job.run(:job1);
 end;
/
begin
 dbms_job.run(:job1);
 end;
/

--删除JOB
begin
  dbms_job.remove(:job1);
  end;
/

--------------------------------------------------------------------

variable job1 number;
begin
  sys.dbms_job.submit
  (job => :job1,
   what => 'INSERT_EXPIRY_DATAS;',
   next_date => trunc(sysdate)+23/24,
   interval => trunc(sysdate,'mi')+1/(24*60));
  commit;
end;


--定义一个数字型变量
declare job1 number;
 begin
 dbms_job.submit(:job1,'test;',sysdate,'sysdate+1/1440');
 end;
 /
 
variable jobno number;
begin
dbms_job.submit(:jobno, 'statspack.snap;', trunc(sysdate+1/24,'HH'), 'trunc(SYSDATE+1/24,''HH'')', TRUE, :instno);
commit;
end;
print jobno



variable job1 number;
begin
  sys.dbms_job.submit
  (job => :job1,
   what => 'INSERT_EXPIRY_DATAS;',
   next_date => trunc(sysdate)+23/24,
   interval => trunc(sysdate,'mi')+1/(24*60));
  commit;
end;


    begin
  sys.dbms_job.submit(job => :job,
                      what => 'check_err;',
                      next_date => trunc(sysdate)+23/24,
                      interval => 'trunc(next_day(sysdate,''星期五''))+23/24');
  commit;
end;

    其中:job是系统自动产生编号,check_err是我的一个过程,next_date设置下次执行时间,这里是今天晚上23:00,interval设置时间间隔,多久执行一次,这里是每周的星期五晚上23:00,函数next_day返回日期中包含指定字符的日期,trunc 函数去掉日期里的时间,也就是得到的是某天的00:00,时间是以天为单位的所以要得到某某点某某分,就需要分数:

1/24    一小时;
1/1440    一分;
1/3600   一秒;

分享到:
评论

相关推荐

    Oracle JOB 用法小结

    Oracle JOB 用法小结 2007-6-20 11:51:36 Oracle JOB 用法小结  一、设置初始化参数 job_queue_processes  sql> alter system set job_queue_processes=n;(n>0)  job_queue_processes最大值为1000    ...

    oracle实验报告

    (1) 了解Oracle的工作环境和基本使用方法。 (2) 练习标准SQL的数据操作,查询命令及其查询优化。 (3) 学会使用高级SQL命令,排序、分组、自连接查询等。 (4) 学会使用SQL*PLUS命令显示报表,存储到文件等。 【实验...

    最完整的Toad For Oracle使用手册

    Unix Job Scheduler 678 Source Control and Team Coding 693 Support for Version Control Products 693 Third Party File Based Source Control 694 Team Coding 697 Status in the Editor Status Bar or Team ...

    oracle安装及备份

    impdp nc55/nc55@nctest directory=expdir dumpfile=ncxh0412.dmp remap_schema=nc55:nc55 logfile=impnc0412.log job_name=impnc55job exp nc55/nc55@ncxh file=D:\*.DMP FULL=Y ---指定用户:owner=(用户1,用户...

    oracle自动分区1

    在oracle的命令行界面执行下面操作,启动一个job:说明: 一些常用命令:--给指定表添加分区alter table TEST3 add partition

    oracle数据库经典题目

    1.在多进程Oracle实例系统中,进程分为用户进程、后台进程和服务进程。 2.标准的SQL语言语句类型可以分为:数据定义语句(DDL)、数据操纵语句(DML)和数据控制语句(DCL)。 3.在需要滤除查询结果中重复的行时,必须...

    利用函数返回oracle对象表的三种方法

    因为要返回表对象,无论后续用... JOB VARCHAR2(9), SAL NUMBER(7,2) ); create or replace type t_test_table as table of t_test; 至于返回表对象的方法,目前发现三种:  1、用数组 create or replace function

    Oracle如何查看impdp正在执行的内容

    SELECT owner_name, job_name, operation, job_mode, state, attached_sessions FROM dba_datapump_jobs; 效果为: 4. 另外开个窗口执行命令: impdp system/Test6530@127.0.0.1/ora19cpdb attach=SY

    Oracle事例

    sql> alter index xay_id allocate extent(size 200k datafile \'c:/oracle/index.dbf\'); <8>.alter index xay_id deallocate unused; 、查看索引 SQL>select index_name,index_type,table_name from user...

    job-manager:独立于业务之外的java任务调用系统

    任务数据存储于MySql上,只支持http的任务回调没有做高可用处理,但是可以加上监控三、API说明api是以swagger的方式提供四、测试说明测试需要启动job-dispatcher-test下的启动springboot测试回调地址为可以观察...

    Oracle数据库基础学习资料整合

    Oracle数据库基础 任务一 1、修改上机的计算机上的文件: product\11.1.0\db_1\NETWORK\ADMIN\tnsnames.ora product\11.1.0\db_1\NETWORK\ADMIN\listener.ora 把文件中的HOST后面的名称更改为...

    数据库服务器字符集更改步骤

    SQL> ALTER SYSTEM SET JOB_QUEUE_PROCESSES=0; SQL> ALTER SYSTEM SET AQ_TM_PROCESSES=0; SQL> ALTER DATABASE OPEN; SQL> alter session set events '10046 trace name context forever,level 12'; SQL> alter ...

    OCP.Java.SE.8.Programmer.II.Exam.Guide.Exam.1Z0-809.7th.2018.pdf

    Study for the OCP Java SE 8 Programmer II exam using this effective exam preparation guide from Oracle Press. Written by a team of experts, including two developers of the original exam, OCP Java SE 8...

    OCA Java SE 8 Programmer I Exam Guide (Exams 1Z0-808) 高清完整azw3版

    Prepare for the OCA Java SE 8 Programmer I exam using this effective self-study system from Oracle Press. Written by developers of the original Sun Certified Java Programmer exam, OCA Java SE 8 ...

    OCA OCP Java SE 7 Programmer I - II Study Guide(SYBEX,2014)

    Prepare for the OCA/OCP Java SE 7 Programmer I and II exams with this exclusive Oracle Press guide. Chapters feature challenging exercises, a certification summary, a two-minute drill, and a self-test...

    OCP Java SE 8 Programmer II Exam Guide (Exam 1Z0-809)

    Study for the OCP Java SE 8 Programmer II exam using this effective exam preparation guide from Oracle Press. Written by a team of experts, including two developers of the original exam, OCP Java SE 8...

    PLSQL.Developer(X64) v12.0.1.1814 主程序+ v11中文包+keygen

    The Test Window now supports Oracle12c implicit results, which are automatically detected and added to the variable list: A new Oracle / Output preference has been added to save dbms_output to a file....

    plsqldev12.0.4.1826x64主程序+ v12中文包+keygen

    The Test Window now supports Oracle12c implicit results, which are automatically detected and added to the variable list: A new Oracle / Output preference has been added to save dbms_output to a file...

    PLSQL.Developer(X32) v12.0.1.1814主程序+ v11中文包+keygen

    The Test Window now supports Oracle12c implicit results, which are automatically detected and added to the variable list: A new Oracle / Output preference has been added to save dbms_output to a file....

    plsqldev12.0.4.1826x32主程序+ v12中文包+keygen

    The Test Window now supports Oracle12c implicit results, which are automatically detected and added to the variable list: A new Oracle / Output preference has been added to save dbms_output to a file...

Global site tag (gtag.js) - Google Analytics