我想在Oracle中重命名调度程序作业,可以吗?
dba_scheduler_jobs(owner = "db", name = "my_job")
=> dba_scheduler_jobs(owner = "db", name = "my_own_job");
感谢您的回答。
作业是数据库对象,因此RENAME命令可在本地运行
SQL> begin
2 dbms_scheduler.create_job (
3 job_name => 'MY_BAD_NAME',
4 job_type => 'PLSQL_BLOCK',
5 job_action => 'begin null; end;',
6 start_date => systimestamp,
7 repeat_interval => 'freq=hourly; byminute=0; bysecond=0;',
8 enabled => true);
9 end;
10 /
PL/SQL procedure successfully completed.
SQL> rename MY_BAD_NAME to BETTER_NAME;
Table renamed.
SQL> select job_name from user_scheduler_jobs;
JOB_NAME
--------------------------------------------------------------------------------
BETTER_NAME
代替重命名,您可以创建/复制作业并删除旧的作业。
下面,my_new_job1已创建。
BEGIN
DBMS_SCHEDULER.CREATE_JOB (
job_name => 'my_new_job1',
program_name => 'my_saved_program',
repeat_interval => 'FREQ=DAILY;BYHOUR=12',
comments => 'Daily at noon');
END;
/
下面,my_new_job2创建的详细信息与my_new_job1相同
BEGIN
DBMS_SCHEDULER.CREATE_JOB (
job_name => 'my_new_job2',
program_name => 'my_saved_program',
repeat_interval => 'FREQ=DAILY;BYHOUR=12',
comments => 'Daily at noon');
END;
/
在旧作业my_new_job1下面已被删除。
BEGIN
DBMS_SCHEDULER.DROP_JOB ('my_new_job1');
END;
/