当前位置:网站首页>Oracle job scheduled task usage details
Oracle job scheduled task usage details
2022-04-23 13:40:00 【Wangcai 2】
oracle Medium job What I can do for you is to execute stored procedures in your specified time format , Perform a task regularly . Here's a small case , Every time 15 Minutes to insert a piece of data into a table
One
1. Create a test table
-- Create table
create table A8
(
a1 VARCHAR2(500)
)
tablespace DSP_DATA
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 64K
next 1M
minextents 1
maxextents unlimited
);
2. Create stored procedure Insert data into the test table
create or replace procedure proc_add_test as
begin
insert into a8 values (to_char(sysdate, 'yyyy-mm-dd hh:mi'));/* Insert data into test table */
commit;
end;
3. establish job Timing task Implement automatic calling of stored procedures ( current time 17:03)
declare
job number;
BEGIN
DBMS_JOB.SUBMIT(
JOB => job, /* Automatic generation JOB_ID*/
WHAT => 'proc_add_test;', /* The name of the stored procedure to execute or SQL sentence */
NEXT_DATE => sysdate+3/(24*60), /* Initial execution time - next 3 minute */
INTERVAL => 'trunc(sysdate,''mi'')+1/(24*60)' /* every other 1 Once per minute */
);
commit;
end;
4. That is to say, we should start from 17:06 Start every other 1 The stored procedure is executed every 15 minutes Here's the deadline 17:12 The data of the test table of points

Two
1. You can query the system table to see the job Information
select * from user_jobs;

2. Manual sql call job ( Call directly job You can ignore the start time )
begin
DBMS_JOB.RUN(40); /*40 job Of id*/
end;
3. Delete task
begin
/* Delete automatically executed job*/
dbms_job.remove(40);
end;
4. stop it job
dbms.broken(job,broken,nextdate);
dbms_job.broken(v_job,true,next_date); /* Stop one job, Inside parameters true But false,next_date( Stop at some point ) But sysdate( Stop at once ). */
5. Modification interval
dbms_job.interval(job,interval);
6. Modify next execution time
dbms_job.next_date(job,next_date);
7. Modify the action to be performed
dbms_job.what(jobno,'sp_fact_charge_code;'); -- Modify a job name
3、 ... and Other intellectual
1. save job Tables of information user_jobs Main field description

2.INTERVAL Examples of common values of parameters
- At midnight every day 12 spot ''TRUNC(SYSDATE + 1)''
- Every day in the morning 8 spot 30 branch ''TRUNC(SYSDATE + 1) + (8*60+30)/(24*60)''
- Every Tuesday at noon 12 spot ''NEXT_DAY(TRUNC(SYSDATE ), ''''TUESDAY'''' ) + 12/24''
- Midnight on the first day of every month 12 spot ''TRUNC(LAST_DAY(SYSDATE ) + 1)''
- On the last night of every quarter 11 spot ''TRUNC(ADD_MONTHS(SYSDATE + 2/24, 3 ), ''Q'' ) -1/24''
- Every Saturday and Sunday morning 6 spot 10 branch ''TRUNC(LEAST(NEXT_DAY(SYSDATE, ''''SATURDAY"), NEXT_DAY(SYSDATE, "SUNDAY"))) + (6×60+10)/(24×60)''
- Every time 3 Once per second 'sysdate+3/(24*60*60)'
- Every time 2 Once per minute 'sysdate+2/(24*60)'
- 1: Every minute
- Interval => TRUNC(sysdate,'mi') + 1/ (24*60) -- Every minute
- interval => 'sysdate+1/(24*60)' -- Every minute
- interval => 'sysdate+1' -- Every day
- interval => 'sysdate+1/24' -- Every hour
- interval => 'sysdate+2/24*60' -- Every time 2 minute
- interval => 'sysdate+30/24*60*60' -- Every time 30 second
- 2: Regular execution every day
- Interval => TRUNC(sysdate+1) -- Every morning 0 Point to perform
- Interval => TRUNC(sysdate+1)+1/24 -- Every morning 1 Point to perform
- Interval => TRUNC(SYSDATE+1)+(8*60+30)/(24*60) -- Every day in the morning 8 spot 30 Points to perform
- 3: Weekly scheduled execution
- Interval => TRUNC(next_day(sysdate,' Monday '))+1/24 -- Every Monday morning 1 Point to perform
- Interval => TRUNC(next_day(sysdate,1))+2/24 -- Every Monday morning 2 Point to perform
- 4: Regular monthly execution
- Interval =>TTRUNC(LAST_DAY(SYSDATE)+1) -- monthly 1 Early morning 0 Point to perform
- Interval =>TRUNC(LAST_DAY(SYSDATE))+1+1/24 -- monthly 1 Early morning 1 Point to perform
- 5: Regular implementation every quarter
- Interval => TRUNC(ADD_MONTHS(SYSDATE,3),'q') -- In the early hours of the first day of each quarter 0 Point to perform
- Interval => TRUNC(ADD_MONTHS(SYSDATE,3),'q') + 1/24 -- In the early hours of the first day of each quarter 1 Point to perform
- Interval => TRUNC(ADD_MONTHS(SYSDATE+ 2/24,3),'q')-1/24 -- The night of the last day of each quarter 11 Point to perform
- 6: Regular implementation every half a year
- Interval => ADD_MONTHS(trunc(sysdate,'yyyy'),6)+1/24 -- Every year, 7 month 1 Day and 1 month 1 Early morning 1 spot
- 7: Regular execution every year
- Interval =>ADD_MONTHS(trunc(sysdate,'yyyy'),12)+1/24 -- Every year, 1 month 1 Early morning 1 Point to perform
Reproduced in Oracle Job Detailed explanation of the use of scheduled tasks - Chestnuts - Blog Garden
版权声明
本文为[Wangcai 2]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230604301039.html
边栏推荐
- Plato farm, a top-level metauniverse game, has made frequent positive moves recently
- 面试官给我挖坑:单台服务器并发TCP连接数到底可以有多少 ?
- GDB的使用
- Lenovo Savior y9000x 2020
- Double pointer instrument panel reading (I)
- Solve the problem that Oracle needs to set IP every time in the virtual machine
- 解决tp6下载报错Could not find package topthink/think with stability stable.
- What do the raddr and rport in webrtc ice candidate mean?
- UEFI learning 01-arm aarch64 compilation, armplatformpripeicore (SEC)
- Campus takeout system - "nongzhibang" wechat native cloud development applet
猜你喜欢

Android clear app cache

交叉碳市场和 Web3 以实现再生变革
![[official announcement] Changsha software talent training base was established!](/img/ee/0c2775efc4578a008c872022a95559.png)
[official announcement] Changsha software talent training base was established!

SAP ui5 application development tutorial 72 - trial version of animation effect setting of SAP ui5 page routing

You and the 42W bonus pool are one short of the "Changsha bank Cup" Tencent yunqi innovation competition!

9419 page analysis of the latest first-line Internet Android interview questions

MySQL5. 5 installation tutorial

Example interview | sun Guanghao: College Club grows and starts a business with me

Tangent space

Why do you need to learn container technology to engage in cloud native development
随机推荐
Opening: identification of double pointer instrument panel
TIA博途中基於高速計數器觸發中斷OB40實現定點加工動作的具體方法示例
Feature Engineering of interview summary
5 tricky activity life cycle interview questions. After learning, go and hang the interviewer!
Remove the status bar
Machine learning -- PCA and LDA
Tersus notes employee information 516 MySQL query (time period uniqueness judgment of 2 fields)
“湘见”技术沙龙 | 程序员&CSDN的进阶之路
GDB的使用
超40W奖金池等你来战!第二届“长沙银行杯”腾讯云启创新大赛火热来袭!
Example of specific method for TIA to trigger interrupt ob40 based on high-speed counter to realize fixed-point machining action
[point cloud series] foldingnet: point cloud auto encoder via deep grid deformation
[indicators] precision, recall
Scons build embedded ARM compiler
9419 page analysis of the latest first-line Internet Android interview questions
Vscode tips
Test on the time required for Oracle to delete data with delete
[dynamic programming] 221 Largest Square
Logstash数据处理服务的输入插件Input常见类型以及基本使用
playwright控制本地谷歌浏览打开,并下载文件