Chinaunix首页 | 论坛 | 博客
  • 博客访问: 239120
  • 博文数量: 59
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 592
  • 用 户 组: 普通用户
  • 注册时间: 2014-04-01 12:51
个人简介

你们都是我的客户,所以,我对你们是透明的

文章分类

全部博文(59)

文章存档

2016年(29)

2015年(30)

分类: Oracle

2015-12-16 14:27:14

Job 初窥探

SQL> show user

USER is "SA"

SQL>

 

创建测试表

SQL> create table aa(

  2  bb varchar2(20)

  3  );

 

Table created.

 

插入

SQL> insert into aa select sysdate from dual;

1 row created.

SQL> select * from test;

T_DATE

---------

16-DEC-15

SQL>

 

SQL> select to_char(t_date,'day') from aa;

TO_CHAR(T

---------

tuesday

SQL>

 

创建存储过程anty aa插入数据

 SQL> create or replace procedure anty

  2     as

  3     begin

  4       insert into aa select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual;

  5     end anty;

  6  /

Procedure created.

 

查看插入的数据

SQL> select * from aa;

BB

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

2015-12-16 13:44:33

16-DEC-15

 

调用一下存储过程

SQL> exec anty;

PL/SQL procedure successfully completed.

SQL> /

BB

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

2015-12-16 13:44:33

16-DEC-15

2015-12-16 14:08:01

SQL>

 

声明一个job,每10s执行一次存储过程

SQL> declare

  2        jobn number;

  3   begin

  4       sys.dbms_job.submit(jobn,'anty;',sysdate,'sysdate+10/86400');

  5       commit;

  6   end;

  7  /

PL/SQL procedure successfully completed.

SQL>

 

手动运行job

SQL> select job,what from user_jobs;

       JOB WHAT

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

         1 anty;

SQL>

SQL> begin

  2  dbms_job.run(1);

  3  end;

  4  /

PL/SQL procedure successfully completed.

 

查看表空间数据文件大小

SQL> select name,bytes from v$datafile;

 

NAME                                          BYTES

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

/oracle/oradata/orcl/system01.dbf         461373440

/oracle/oradata/orcl/undotbs01.dbf         26214400

/oracle/oradata/orcl/sysaux01.dbf         272629760

/oracle/oradata/orcl/users01.dbf            5242880

/oracle/oradata/orcl/ant_1.dbf            104857600

/oracle/oradata/orcl/EPICARD.DBF           10485760

6 rows selected.

SQL>

 

删除一个job

SQL> begin

  2  dbms_job.remove(1);

  3  end;

  4  /

PL/SQL procedure successfully completed.

SQL>

 

阅读(1264) | 评论(0) | 转发(0) |
0

上一篇:pygame 一个很简单的窗口

下一篇:ora 1102

给主人留下些什么吧!~~