当前位置:网站首页>Oracle stored procedure and job task setting
Oracle stored procedure and job task setting
2022-07-02 04:38:00 【Mr. No】
oracle stored procedure , Delete Syntax
Query syntax field parsing :
Field ( Column ) type describe
JOB NUMBER Unique identification number of the task
LOG_USER VARCHAR2(30) Users submitting tasks
PRIV_USER VARCHAR2(30) Users with task permissions
SCHEMA_USER VARCHAR2(30) User pattern for task parsing
LAST_DATE DATE Time of the last successful run of the task
LAST_SEC VARCHAR2(8) Such as HH24:MM:SS Format last_date Hour of date , Minutes and seconds
THIS_DATE DATE Start time of running task , If the task is not running; otherwise null
THIS_SEC VARCHAR2(8) Such as HH24:MM:SS Format this_date Hour of date , Minutes and seconds
NEXT_DATE DATE Time of next scheduled task
NEXT_SEC VARCHAR2(8) Such as HH24:MM:SS Format next_date Hour of date , Minutes and seconds
TOTAL_TIME NUMBER The total time required for the task to run , The unit is in seconds
BROKEN VARCHAR2(1) Flag parameter ,Y Mark task interruption , Will not run in the future
INTERVAL VARCHAR2(200) Expression used to calculate the next run time
FAILURES NUMBER Number of consecutive unsuccessful tasks
WHAT VARCHAR2(2000) Performing tasks PL/SQL block
CURRENT_SESSION_LABELRAW MLSLABEL Trust for this task Oracle Session symbol
CLEARANCE_HI RAW MLSLABEL The task is trustworthy Oracle Maximum clearance
CLEARANCE_LO RAW MLSLABEL The task is trustworthy Oracle Minimum clearance
NLS_ENV VARCHAR2(2000) Task running NLS Session settings
MISC_ENV RAW(32) Some other session parameters for task running
Query task :
select * from dba_jobs;
select * from all_jobs;
select * fromuser_jobs;
Running job
select * from dba_jobs_running;
Create stored procedure :
CREATE OR REPLACE procedure DELETE_MSG_POTENTIAL_VICTIM is
begin
begin
delete from MSG_POTENTIAL_VICTIM where TO_CHAR (CREATETIME,'YYYY-MM-DD') = TO_CHAR(SYSDATE -1,'YYYY-MM-DD');
commit;
end;
end;
oracle stored procedure , Delete partition data
CREATE OR REPLACE PROCEDURE add_part_moth IS
v_1 VARCHAR2(500);
v_4 VARCHAR2(1000);
v_5 VARCHAR2(1000);
BEGIN
v_1 := 'p_' || to_char(add_months(SYSDATE,1),'YYYYMM');
v_2 := to_number(to_char(TRUNC(add_months(SYSDATE,2), 'MM'),'YYYYMMDD'));
v_4 := 'alter table MOBILE_CALLEDZONE_MONTH add partition ' || v_1 || ' values less than (TO_DATE(' || '''' || v_2 || ' 00:00:00' || '''' || ',' || '''' || 'YYYYMMDD HH24:MI:SS' || '''' || ')) tablespace plsspace_stat';
v_5 := 'alter table NUMBERS_MONTH add partition ' || v_1 || ' values less than (TO_DATE(' || '''' || v_2 || ' 00:00:00' || '''' || ',' || '''' || 'YYYYMMDD HH24:MI:SS' || '''' || ')) tablespace plsspace_stat';
BEGIN
EXECUTE IMMEDIATE v_4;
END;
BEGIN
EXECUTE IMMEDIATE v_5;
END;
END;
Oracle Of To configure job Mission
-- establish stored procedure job
declare
job binary_integer;
begin
dbms_job.submit(job => job,
what => 'DELETE_MSG_POTENTIAL_VICTIM();',
next_date => sysdate, -- Execute now
interval => 'sysdate + 1 / 24' -- Hourly execution
);
commit;
end;
-- Inquire about job Task list
select * from user_jobs;
select * from dba_jobs
select * from all_jobs
-- modify job cycle
declare
begin
dbms_job.interval(job => 105, interval => 'sysdate + 1 / 24');
commit;
end;
-- Delete stored procedure job
declare
begin
dbms_job.remove(job => 106);
commit;
end;
-- Execute stored procedures now job
declare
begin
dbms_job.run(job => 105);
commit;
end;
select sysdate current time ,
sysdate + 1 Every day ,
sysdate + 1 / 24 Every hour ,
sysdate + 1 / (24 * 60) Every minute ,
sysdate + 1 / (24 * 60 * 60) Per second ,
sysdate + 7 Once a week ,
trunc(sysdate + 1) At midnight every day 12 spot ,
trunc(sysdate + 1) + (8 * 60 + 30) / (24 * 60) Every day in the morning 8 spot 30 branch ,
-- show parameter nls_date_language; 'TUESDAY'
next_day(trunc(sysdate), ' Tuesday ') + 12 / 24 Every Tuesday at noon 12 spot ,
trunc(last_day(sysdate)) + 1 Midnight on the first day of every month 12 spot ,
trunc(add_months(sysdate + 2 / 24, 3), 'Q') - 1 / 24 On the last night of every quarter 11 spot ,
-- Saturday saturday, Sunday sunday
trunc(least(next_day(sysdate, ' Saturday '), next_day(sysdate, ' Sunday '))) +
(6 * 60 + 10) / (24 * 60) Every Saturday and Sunday morning 6 spot 10 branch
from dual;
job Set the time :
Regular execution every day
for example : Every morning 1 Point to perform
Interval =>TRUNC(sysdate) + 1 +1/ (24)
Weekly scheduled execution
for example : Every Monday morning 1 Point to perform
Interval =>TRUNC(next_day(sysdate,' Monday '))+1/24
Regular monthly execution
for example : monthly 1 Early morning 1 Point to perform
Interval=>TRUNC(LAST_DAY(SYSDATE))+1+1/24
Regular implementation every quarter
For example, in the early morning of the first day of each quarter 1 Point to perform
Interval =>TRUNC(ADD_MONTHS(SYSDATE,3),'Q') + 1/24
Regular implementation every half a year
for example : Every year, 7 month 1 Day and 1 month 1 Early morning 1 spot
Interval =>ADD_MONTHS(trunc(sysdate,'yyyy'),6)+1/24
Regular execution every year
for example : Every year, 1 month 1 Early morning 1 Point to perform
Interval=>ADD_MONTHS(trunc(sysdate,'yyyy'),12)+1/24
Reference resources :https://blog.csdn.net/qq_34745941/article/details/99857323
边栏推荐
- 千亿市场规模医疗美容行业的水究竟有多浑?
- 二叉树解题(二)
- 正大美欧4的主账户关注什么数据?
- Idea automatic package import and automatic package deletion settings
- Ten thousand volumes are known to all, and one page of a book is always relevant. TVP reading club will take you through the reading puzzle!
- Deep understanding of lambda expressions
- Mysql表insert中文变?号的问题解决办法
- 洛谷入门3【循环结构】题单题解
- Dare to go out for an interview without learning some distributed technology?
- BGP experiment the next day
猜你喜欢
Thinkphp內核工單系統源碼商業開源版 多用戶+多客服+短信+郵件通知
The solution to the complexity brought by lambda expression
Cache consistency solution - how to ensure the consistency between the cache and the data in the database when changing data
June book news | 9 new books are listed, with a strong lineup and eyes closed!
正大留4的主账户信息汇总
One click generation and conversion of markdown directory to word format
Embedded-c language-9-makefile/ structure / Consortium
MySQL advanced SQL statement 2
Typescript practice for SAP ui5
Use a mask to restrict the input of the qlineedit control
随机推荐
oracle 存储过程与job任务设置
Summary of common string processing functions in C language
I sorted out some basic questions about opencv AI kit.
60后关机程序
Leetcode merge sort linked list
洛谷入门3【循环结构】题单题解
win11安装pytorch-gpu遇到的坑
One step implementation of yolox helmet detection (combined with oak intelligent depth camera)
Realize the function of data uploading
C language practice - number guessing game
Pytorch-Yolov5從0運行Bug解决:
cookie、session、tooken
Free drawing software recommended - draw io
Several methods of capturing packets under CS framework
The core idea of performance optimization, dry goods sharing
C language guessing numbers game
Bitmap principle code record
Why can't you remember when reading? Why can't you remember- My technology learning methodology
第十六周作业
Recyclerview add header