Oracle job learning

Source: Internet
Author: User
No available items are found after searching for a bunch on the Internet. A spauto is found under $ ORACLE_HOMERDBMSadmin in the oracle directory. SQL statement: variablejobnonumber; variableinstnonumber; beginselectinstance_numberinto: instnofromv $ instance; dbms_job.submit (: jobn

No available items are found after searching for a bunch on the Internet. A spauto is found under $ ORACLE_HOME/RDBMS/admin in the oracle directory. SQL statement: variable jobno number; variable instno number; begin select instance_number into: instno from v $ instance; dbms_job.submit (: jobn

I searched a bunch on the Internet and found none of them available. I found one under the oracle directory.

Under $ ORACLE_HOME/RDBMS/admin, there is a spauto. SQL,

The statement is as follows:

Variable jobno number;
Variable instno number;
Begin
Select instance_number into: instno from v $ instance;
Dbms_job.submit (: jobno, 'statspack. snap; ', trunc (sysdate + 1/24, 'hh'), 'trunc (SYSDATE + 1/24, ''hh '')', TRUE,: instno );
Commit;
End;
/

Run the command on the pl/SQL command line. For more information about other syntaxes, see

--- Set the execution of p_job_run_day in a certain time period
Declare
Jobid number;
V_ SQL varchar2 (2000 );
V_day_id number;
Begin
SELECT to_number (to_char (SYSDATE-1, 'yyyymmdd') INTO v_day_id FROM dual;
V_ SQL: = 'begin'
If to_char (sysdate, ''hh24: mi'') = ''7: 00''
Then p_job_run_day;
Dbms_output.put_line (''success '');
End if;
Commit;
Exception
When others then
Rollback;
Dbms_output.put_line (SQLERRM );
End ;';
Dbms_job.submit (jobid, v_ SQL, sysdate, 'sysdate + 1/24 ');
Dbms_job.run (jobid );
Dbms_output.put_line ('job' | to_char (jobid) | 'is running ');
Commit;
End;
/


2. delete a job
Find the job number from select * from user_jobs;
Execute exec dbms_job.remove (22 );

3. If the execution time is controlled

3
Parameter Value of INTERVAL
'Trunc (SYSDATE + 1) 'At midnight every day )'
Every morning 08:30 'trunc (SYSDATE + 1) + (8*60 + 30)/(24*60 )'
NEXT _ DAY (TRUNC (SYSDATE), ''tuesday'') + 12/24 at every TUESDAY'
'Trunc (LAST_DAY (SYSDATE) + 1) 'at midnight on the first day of each month )'
'Trunc (ADD_MONTHS (SYSDATE + 2/24, 3), 'q')-100' at on the last day of each quarter'
'Trunc (LEAST (NEXT_DAY (SYSDATE, ''saturday "), NEXT_DAY (SYSDATE," SUNDAY ") + (6 × 60 + 10) /(24 × 60 )'

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.