带有绑定变量的 Oracle SQL 跟踪

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

Oracle SQL trace with bind variables

sqloracletracebind-variables

提问by gabor

How to aquire the full SQL statement with bind variables substituted from a trace file?

如何使用从跟踪文件中替换的绑定变量获取完整的 SQL 语句?

When setting

设置时

ALTER SESSION SET EVENTS '10046 trace name context forever, level 4';
ALTER SESSION SET sql_trace = true;

the resulting trace file contains the SQL query with bind variables and the resolution of the bind variables in a separate "BINDS" section. This is fine if there are a couple of bind variables. It's not very useful when I have 100+ bind variables.

生成的跟踪文件在单独的“BINDS”部分中包含带有绑定变量的 SQL 查询和绑定变量的解析。如果有几个绑定变量,这很好。当我有 100 多个绑定变量时,这不是很有用。

Tkprof processes the trace file but does not support bind variables.

Tkprof 处理跟踪文件但不支持绑定变量。

Is it possible to get the full SQL statements with the bind variables substituted so I can easily copy-paste and re-execute it? Is there maybe a free tool that will process my trace file and output the full SQL statements?

是否可以使用替换的绑定变量获取完整的 SQL 语句,以便我可以轻松地复制粘贴并重新执行它?是否有免费工具可以处理我的跟踪文件并输出完整的 SQL 语句?

I'd also appreciate a solution without SQL tracing using v$sql and friends instead.

我也很欣赏一个没有 SQL 跟踪的解决方案,而是使用 v$sql 和朋友。

回答by jsampath

You need to use Oracle trace analyzer instead of tkprof to extract actual values of bind variables. http://www.rampant-books.com/art_moore_oracle_trace_analyzer_trcanlzr_sql.htm

您需要使用 Oracle 跟踪分析器而不是 tkprof 来提取绑定变量的实际值。http://www.rampant-books.com/art_moore_oracle_trace_analyzer_trcanlzr_sql.htm

trace analyzer is going to replace eventually tkprof in future.

跟踪分析器将在未来最终取代 tkprof。