当前位置:网站首页>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
边栏推荐
- TIA博途中基于高速计数器触发中断OB40实现定点加工动作的具体方法示例
- Innobackupex incremental backup
- [point cloud series] pointfilter: point cloud filtering via encoder decoder modeling
- Resolution: argument 'radius' is required to be an integer
- Common analog keys of ADB shell: keycode
- Feature Engineering of interview summary
- What does the SQL name mean
- playwright控制本地谷歌浏览打开,并下载文件
- @Excellent you! CSDN College Club President Recruitment!
- CSDN高校俱乐部“名师高校行”——湖南师范大学站
猜你喜欢
Esp32 vhci architecture sets scan mode for traditional Bluetooth, so that the device can be searched
[point cloud series] learning representations and generative models for 3D point clouds
TERSUS笔记员工信息516-Mysql查询(2个字段的时间段唯一性判断)
Imx6ull QEMU bare metal tutorial 1: GPIO, iomux, I2C
[Video] Bayesian inference in linear regression and R language prediction of workers' wage data | data sharing
面试官给我挖坑:单台服务器并发TCP连接数到底可以有多少 ?
Exemple de méthode de réalisation de l'action d'usinage à point fixe basée sur l'interruption de déclenchement du compteur à grande vitesse ob40 pendant le voyage de tia Expo
@Excellent you! CSDN College Club President Recruitment!
You and the 42W bonus pool are one short of the "Changsha bank Cup" Tencent yunqi innovation competition!
Set Jianyun x Feishu Shennuo to help the enterprise operation Department realize office automation
随机推荐
Android clear app cache
Publish custom plug-ins to local server
Imx6ull QEMU bare metal tutorial 1: GPIO, iomux, I2C
[andorid] realize SPI communication between kernel and app through JNI
Analysis of the latest Android high frequency interview questions in 2020 (BAT TMD JD Xiaomi)
零拷贝技术
Uninstall MySQL database
TERSUS笔记员工信息516-Mysql查询(2个字段的时间段唯一性判断)
playwright控制本地谷歌浏览打开,并下载文件
CSDN College Club "famous teacher college trip" -- Hunan Normal University Station
GDB的使用
Machine learning -- model optimization
Migrating your native/mobile application to Unified Plan/WebRTC 1.0 API
Solve the problem that Oracle needs to set IP every time in the virtual machine
面试官给我挖坑:URI中的 “//” 有什么用?
@Excellent you! CSDN College Club President Recruitment!
这个SQL语名是什么意思
Example interview | sun Guanghao: College Club grows and starts a business with me
TCP reset Gongji principle and actual combat reproduction
RTOS mainstream assessment