当前位置:网站首页>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
边栏推荐
- Gin framework learning code
- Embedded-c language-8-character pointer array / large program implementation
- Three years of experience in Android development interview (I regret that I didn't get n+1, Android bottom development tutorial
- 【提高课】ST表解决区间最值问题【2】
- A summary of common interview questions in 2022, including 25 technology stacks, has helped me successfully get an offer from Tencent
- win10 磁盘管理 压缩卷 无法启动问题
- Unity particle Foundation
- [C language] basic learning notes
- Idea automatic package import and automatic package deletion settings
- Pit encountered in win11 pytorch GPU installation
猜你喜欢

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!

缓存一致性解决方案——改数据时如何保证缓存和数据库中数据的一致性

UNET deployment based on deepstream

Read "the way to clean code" - function names should express their behavior

Introduction to vmware workstation and vSphere

MySQL table insert Chinese change? Solution to the problem of No

My first experience of shadowless cloud computer

win11安装pytorch-gpu遇到的坑

Learn what definitelytyped is through the typescript development environment of SAP ui5

Tawang food industry insight | current situation, consumption data and trend analysis of domestic infant complementary food market
随机推荐
10 minutes to understand CMS garbage collector in JVM
Recyclerview add header
深圳打造全球“鸿蒙欧拉之城”将加快培育生态,优秀项目最高资助 1000 万元
Introduction to JSON usage scenarios and precautions
Today's plan: February 15, 2022
【提高课】ST表解决区间最值问题【2】
cookie、session、tooken
Pit encountered in win11 pytorch GPU installation
Pytorch---使用Pytorch进行图像定位
Pytorch-Yolov5從0運行Bug解决:
C language practice - binary search (half search)
Yyds dry goods inventory kubernetes introduction foundation pod concept and related operations
Spring moves are coming. Watch the gods fight
WiFi 5GHz frequency
Thinkphp内核工单系统源码商业开源版 多用户+多客服+短信+邮件通知
Use a mask to restrict the input of the qlineedit control
Ognl和EL表达式以及内存马的安全研究
CorelDRAW graphics suite2022 free graphic design software
geotrust ov多域名ssl證書一年兩千一百元包含幾個域名?
Mysql中常见的锁