当前位置:网站首页>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
边栏推荐
- Pytoch --- use pytoch for image positioning
- 二叉樹解題(二)
- LCM of Spreadtrum platform rotates 180 °
- 正大美欧4的主账户关注什么数据?
- Federal learning: dividing non IID samples according to Dirichlet distribution
- Wechat applet calculates the distance between the two places
- 洛谷入门3【循环结构】题单题解
- 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!
- Actual combat | use composite material 3 in application
- 10 minutes to understand CMS garbage collector in JVM
猜你喜欢

The core idea of performance optimization, dry goods sharing

Thinkphp Kernel wo system source Commercial Open source multi - user + multi - Customer Service + SMS + email notification

Pytoch --- use pytoch to realize u-net semantic segmentation

云服务器的安全设置常识

A summary of common interview questions in 2022, including 25 technology stacks, has helped me successfully get an offer from Tencent

Deep understanding of lambda expressions

阿里云polkit pkexec 本地提权漏洞

CorelDRAW graphics suite2022 free graphic design software

66.qt quick QML Custom Calendar component (supports vertical and horizontal screens)

MySQL advanced SQL statement 2
随机推荐
Cache consistency solution - how to ensure the consistency between the cache and the data in the database when changing data
Keil compilation code of CY7C68013A
Free drawing software recommended - draw io
Mysql database learning
Binary tree problem solving (1)
Alibaba cloud polkit pkexec local rights lifting vulnerability
There is no prompt for SQL in idea XML, and the dialect setting is useless.
cookie、session、tooken
Yyds dry inventory compiler and compiler tools
Landing guide for "prohibit using select * as query field list"
Common sense of cloud server security settings
【毕业季·进击的技术er】年少有梦,何惧彷徨
Pit encountered in win11 pytorch GPU installation
How to write a client-side technical solution
Major domestic quantitative trading platforms
cs架构下抓包的几种方法
Binary tree problem solving (2)
ThinkPHP kernel work order system source code commercial open source version multi user + multi customer service + SMS + email notification
初学爬虫-笔趣阁爬虫
One step implementation of yolox helmet detection (combined with oak intelligent depth camera)