oracle 如何检查oracle中长时间运行的插入进度

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27817470/
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-19 02:41:02  来源:igfitidea点击:

How to check progress of long running insertions in oracle

sqloracleoracle11g

提问by user3004110

I am trying to insert 1 million record after performing some calculation on each row in oracle. 15 hours gone and it is still in works. When i write a select query on this table it shows nothing. I don't know where is my inserted data going on each insert.

在对 oracle 中的每一行执行一些计算后,我试图插入 100 万条记录。15 小时过去了,它仍在工作中。当我在这个表上写一个选择查询时,它什么也没显示。我不知道每次插入时插入的数据在哪里。

So my question is that, is there any way to check how many rows insert till now while performing long running insertion in oracle table, thanks.

所以我的问题是,在 oracle 表中执行长时间运行插入时,有没有办法检查到目前为止插入了多少行,谢谢。

回答by Lalit Kumar B

It depends whether you are doing the insertion in SQLor PL/SQL. While using PL/SQLyou have your own ways to get the number of rows already been processed, you can of course write your own program.

这取决于您是在SQL还是中进行插入PL/SQL。在使用时,PL/SQL您有自己的方法来获取已处理的行数,当然您也可以编写自己的程序。

Coming to SQL, I can think of two ways :

说到这里SQL,我可以想到两种方法:

  • V$SESSION_LONGOPS
  • V$TRANSACTION
  • V$SESSION_LONGOPS
  • V$交易

Most of the GUI based toolswould have nice graphical representation for the long operations view. You can query -

GUI based tools对于长期操作视图,大多数都有很好的图形表示。您可以查询-

SELECT ROUND(SOFAR*21411/TOTALWORK)
FROM V$SESSION_LONGOPS
WHERE username     = '<username>'
AND TIME_REMAINING > 0

The V$TRANSACTIONview can tell you whether any transaction is still pending. If your INSERTis completed and COMMITis issued, the transaction would be completed. You can joinit with v$session. You can query -

V$TRANSACTION视图可以告诉您是否有任何事务仍处于待处理状态。如果您INSERT的完成并COMMIT发出,则交易将完成。你可以joinv$session. 您可以查询-

SELECT     .... 
from       v$transaction t 
inner join v$session s 
ON         t.addr = s.taddr;