简体   繁体   English

如何在ORACLE中获取所有执行的SQL查询?

[英]How to get all executed SQL queries in ORACLE?

Is possible to find out all SQL queries and their return code, which was executed in Oracle database? 有可能找出所有在Oracle数据库中执行的SQL查询及其返回码吗? Specially I want to get all sql queries which has negative sql code (error). 特别是我想获得所有具有负sql代码的SQL查询(错误)。

Thank you for answer. 谢谢你的答案。

Everything which was executed? 所有被执行的东西? That would require enabling auditing , and fine-grained auditing to boot - and auditing every statement in a database can generate a lot of data. 这需要启用审计和细粒度审计来启动 - 并且审计数据库中的每个语句都可以生成大量数据。

Maybe you can execute your queries within a (anonymous) PL/SQL block, and then use the its exception handler to catch "negative" statements: 也许您可以在(匿名)PL / SQL块中执行查询,然后使用其异常处理程序来捕获“否定”语句:

begin
  insert into a values (1, 4/0);
exception when others then
  ... error has happened,
  ... use 'sqlerrm' and 'sqlcode' 
  ... for further analysis
end;

如果你想要任何错误代码的解决方案,请查看Oracle文档的错误消息pdf,其中你找到了各种错误代码及其描述....

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM