database 如何停止 Oracle dbms_job

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/40989907/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 08:03:11  来源:igfitidea点击:

How to stop Oracle dbms_job

databaseoracledbms-job

提问by mike.jiang

My dbms_job has been running for nearly thirty days.

我的 dbms_job 已经运行了将近三十天了。

The number of total time keeps rising, but I can't find any info of the running job.

总时间不断增加,但我找不到正在运行的作业的任何信息。

When I execute sql that is "select * from dba_jobs;", the result shows no job is running.

当我执行“select * from dba_jobs;”的sql时,结果显示没有作业正在运行。

I set it to broken, but it doesn't work.

我把它设置为损坏,但它不起作用。

How can I stop this dbms_job safely?

我怎样才能安全地停止这个 dbms_job?

the job's information

工作信息

回答by JSapkota

DBA_JOBSlists all the jobs created in the database. You could use DBA_JOBS_RUNNINGview to list all jobs that are currently running in the instance.

DBA_JOBS列出在数据库中创建的所有作业。您可以使用DBA_JOBS_RUNNING视图列出当前在实例中运行的所有作业。

When I execute sql that is "select * from dba_jobs;", the result shows no job is running.

当我执行“select * from dba_jobs;”的sql时,结果显示没有作业正在运行。

This shows all the jobs created using DBMS_JOBSpackage. The job might have created using DBMS_SCHEDULERpackage.

这将显示使用DBMS_JOBSpackage创建的所有作业。作业可能是使用DBMS_SCHEDULER包创建的。

SQL> select job from user_jobs;

       JOB
----------
        99

I have created only one job using DBMS_JOBpackage which is called 99. Others are created using DBMS_SCHEDULERpackage which can be seen using:

我只使用DBMS_JOB名为99. 其他是使用DBMS_SCHEDULER包创建的,可以使用以下命令查看:

SQL> select job_name from user_scheduler_jobs;

As per the documentation-

根据文档-

Stopping a Job

Note that, once a job is started and running, there is no easy way to stop the job.

停止作业

请注意,一旦作业启动并运行,就没有简单的方法来停止作业。

Its not easy to stop the job.

停止工作并不容易。

Don't know which version of Oracle database are you using. But starting with Oracle 10g You use the following query to list the scheduled jobs.

不知道您使用的是哪个版本的 Oracle 数据库。但是从 Oracle 10g 开始,您可以使用以下查询列出计划的作业。

SQL>select * from all_scheduler_jobs;

ALL_SCHEDULER_JOBS

ALL_SCHEDULER_JOBS displays information about the Scheduler jobs accessible to the current user.More...

ALL_SCHEDULER_JOBS

ALL_SCHEDULER_JOBS 显示有关当前用户可访问的调度程序作业的信息。更多的...


Use the following query to find the currently running job.


使用以下查询查找当前正在运行的作业。

SQL>select job_name, session_id, running_instance, elapsed_time, cpu_used
from user_scheduler_running_jobs;

And to stop-

并停止-

SQL>EXEC DBMS_SCHEDULER.STOP_JOB (job_name => 'JOB_NAME');

回答by user12722481

checkout SID in "select * from DBA_JOBS_RUNNNG" thats session ID kill that session and thats it changes will be rolled back, so it can take "more" time to abort than letting it finish if that bulk update was 90% complete....

在“select * from DBA_JOBS_RUNNNG”中签出 SID,会话 ID 会终止该会话,并且更改将被回滚,因此如果批量更新完成 90%,它可能需要“更多”的时间来中止而不是让它完成......

回答by Frank Schmitt

Short of killing the session, you're out of luck.

没有杀死会话,你就不走运了。

From the Documentation:

文档

Note that, once a job is started and running, there is no easy way to stop the job.

请注意,一旦作业启动并运行,就没有简单的方法来停止作业。

That's one of the many reasons why you shouldn't use dbms_jobanymore. Use dbms_schedulerinstead.

这是您不应再使用的众多原因之一dbms_job。使用dbms_scheduler来代替。