To create a scheduled task that is executed once a day in Oracle, you need to perform the following three steps: Create a job. Add a subjob to the job and set its schedule expression to "INTERVAL 1 DAY". Enable the job.
How to create a scheduled task that is executed once a day in Oracle
Create a scheduled task that is executed once a day in Oracle The steps of the task are as follows:
1. Create a job
<code>CREATE JOB job_name AS sys.dbms_scheduler.create_job(job_name, 'DEFAULT_JOB_CLASS', 'job_desc');</code>
where:
2. Add a sub-job to the job
<code>sys.dbms_scheduler.create_job_subjob(job_name, 'job_subname', 'job_type', 'job_parameters', 'schedule_expression', 'enabled');</code>
where :
3. Enable jobs
<code>sys.dbms_scheduler.enable(job_name);</code>
Example (using SQL to execute a simple SELECT query)
<code>CREATE JOB daily_job AS sys.dbms_scheduler.create_job(job_name, 'DEFAULT_JOB_CLASS', 'Daily job to execute a SQL query'); sys.dbms_scheduler.create_job_subjob(job_name, 'daily_subjob', 'SQL', 'BEGIN SELECT COUNT(*) FROM users; END;', 'INTERVAL 1 DAY', 'TRUE'); sys.dbms_scheduler.enable(job_name);</code>
The above is the detailed content of Oracle scheduled tasks execute the creation step once a day. For more information, please follow other related articles on the PHP Chinese website!