当前位置:网站首页>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
边栏推荐
- geotrust ov多域名ssl证书一年两千一百元包含几个域名?
- Embedded-c language-9-makefile/ structure / Consortium
- My first experience of shadowless cloud computer
- Cache consistency solution - how to ensure the consistency between the cache and the data in the database when changing data
- Design and implementation of general interface open platform - (44) log processing of API services
- Leetcode merge sort linked list
- [C language] basic learning notes
- Okcc why is cloud call center better than traditional call center?
- Recyclerview add header
- 洛谷入门3【循环结构】题单题解
猜你喜欢

Several methods of capturing packets under CS framework

C language practice - number guessing game

Common sense of cloud server security settings

Typescript practice for SAP ui5

阿里云polkit pkexec 本地提权漏洞

Idea automatic package import and automatic package deletion settings

Tawang food industry insight | current situation, consumption data and trend analysis of domestic infant complementary food market

Gin framework learning code

正大留4的主账户信息汇总

Alibaba cloud polkit pkexec local rights lifting vulnerability
随机推荐
正大美欧4的主账户关注什么数据?
[understand one article] FD_ Use of set
记录一次Unity 2020.3.31f1的bug
Pytorch-Yolov5从0运行Bug解决:
初学爬虫-笔趣阁爬虫
Websites that it people often visit
Design and implementation of general interface open platform - (44) log processing of API services
Read "the way to clean code" - function names should express their behavior
66.qt quick QML Custom Calendar component (supports vertical and horizontal screens)
10 minutes to understand CMS garbage collector in JVM
C language practice - number guessing game
深圳打造全球“鸿蒙欧拉之城”将加快培育生态,优秀项目最高资助 1000 万元
Pytorch---使用Pytorch实现U-Net进行语义分割
千亿市场规模医疗美容行业的水究竟有多浑?
Wechat applet calculates the distance between the two places
Spring recruitment of Internet enterprises: Kwai meituan has expanded the most, and the annual salary of technical posts is up to nearly 400000
[C language] Dynamic Planning --- from entry to standing up
C语言猜数字游戏
Yolov5 network modification tutorial (modify the backbone to efficientnet, mobilenet3, regnet, etc.)
Federal learning: dividing non IID samples according to Dirichlet distribution