当前位置:网站首页>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
边栏推荐
- office_ Delete the last page of word (the seemingly blank page)
- 云服务器的安全设置常识
- Wechat applet map annotation
- Mysql中常见的锁
- Spring moves are coming. Watch the gods fight
- Leetcode- insert and sort the linked list
- Deep understanding of lambda expressions
- 深圳打造全球“鸿蒙欧拉之城”将加快培育生态,优秀项目最高资助 1000 万元
- Spring recruitment of Internet enterprises: Kwai meituan has expanded the most, and the annual salary of technical posts is up to nearly 400000
- win11安装pytorch-gpu遇到的坑
猜你喜欢
Alibaba cloud polkit pkexec local rights lifting vulnerability
Shenzhen will speed up the cultivation of ecology to build a global "Hongmeng Oula city", with a maximum subsidy of 10million yuan for excellent projects
Pytoch --- use pytoch for image positioning
What is 5g industrial wireless gateway? What functions can 5g industrial wireless gateway achieve?
记录一次Unity 2020.3.31f1的bug
Ognl和EL表达式以及内存马的安全研究
FAQ | FAQ for building applications for large screen devices
DC-1靶场搭建及渗透实战详细过程(DC靶场系列)
Gin framework learning code
Yolov5 network modification tutorial (modify the backbone to efficientnet, mobilenet3, regnet, etc.)
随机推荐
Several methods of capturing packets under CS framework
记录一次Unity 2020.3.31f1的bug
【提高课】ST表解决区间最值问题【2】
二叉樹解題(二)
Typescript practice for SAP ui5
Mysql中常见的锁
ThinkPHP kernel work order system source code commercial open source version multi user + multi customer service + SMS + email notification
Handling of inconsistency between cursor and hinttext position in shutter textfield
Vmware安装win10报错:operating system not found
Deeply understand the concepts of synchronization and asynchrony, blocking and non blocking, parallel and serial
win11安装pytorch-gpu遇到的坑
I sorted out some basic questions about opencv AI kit.
Design and implementation of general interface open platform - (44) log processing of API services
Pytoch --- use pytoch for image positioning
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!
There is no prompt for SQL in idea XML, and the dialect setting is useless.
Leetcode merge sort linked list
LCM of Spreadtrum platform rotates 180 °
Mapping location after kotlin confusion
Mysql database learning