oracle 如何在oracle中查找在表上运行的查询
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3387114/
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
How to find queries running on a table in oracle
提问by Walker
I ran a SQL Delete from a SQL Developer session and the delete was running for a long time since there were large number of records. Due to some Not Responding problem with SQL Developer client, i lost my session, as the SQL Developer window got closed.
我从 SQL Developer 会话中运行了 SQL 删除,并且删除运行了很长时间,因为有大量记录。由于 SQL Developer 客户端的一些无响应问题,我失去了会话,因为 SQL Developer 窗口关闭了。
I do not have DBA access rights, i can not query views like v$session, v$sqlarea etc. But the SQL is still running on database. As soon as i insert some records, it deletes them. How can i find / confirm that this query is still running before asking the DBA to kill this query.
我没有 DBA 访问权限,无法查询 v$session、v$sqlarea 等视图。但 SQL 仍在数据库上运行。一旦我插入一些记录,它就会删除它们。在要求 DBA 终止此查询之前,我如何找到/确认此查询仍在运行。
回答by APC
"But the SQL is still running on database. As soon as i insert some records, it deletes them."
“但 SQL 仍在数据库上运行。只要我插入一些记录,它就会删除它们。”
It is a bit hard to believe this. If your "SQL Delete" was a straightforward DELETE FROM your_table
then it cannot be deleting your new records. Oracle's read consistency model won't allow it. So, either you are mistaken or you did something a lot more complicated.
有点难以相信这一点。如果您的“SQL 删除”很简单,DELETE FROM your_table
那么它就不能删除您的新记录。Oracle 的读取一致性模型不允许这样做。所以,要么你错了,要么你做了更复杂的事情。
If you have issued a long running DELETE it may show up as long operation in the view V$SESSION_LONGOPS. Not everything is included. Find out more.
如果您发出了长时间运行的 DELETE,它可能会在视图 V$SESSION_LONGOPS 中显示为长时间操作。并非所有内容都包括在内。 了解更多。
select sid
, serial#
, opname
, sofar
, totalwork
, start_time
, last_update_time
, time_remaining
, elapsed_seconds
, sql_address
, sql_hash_value
, sql_id
from v$session_longops
where username = &your_username
and time_remaining != 0 ;
Without DBA access you won't be able to use the information such as SQL_ADDRESS to look up the precise SQL being run in V$SQL. But hopefully you won't have too many hits.
如果没有 DBA 访问权限,您将无法使用诸如 SQL_ADDRESS 之类的信息来查找在 V$SQL 中运行的精确 SQL。但希望你不会有太多的点击。
回答by Rob van Laarhoven
You should go to your DBA, explain what you think is happening and together analyse the problem.
您应该去找您的 DBA,解释您认为正在发生的事情并一起分析问题。
This part of your question puzzles me:
你问题的这一部分让我感到困惑:
As soon as i insert some records, it deletes them.
一旦我插入一些记录,它就会删除它们。
The delete transaction you started can not delete records that you insert after you started the delete transaction, this is called read consistency.
您启动的删除事务不能删除您启动删除事务后插入的记录,这称为读一致性。