alter system set events '10046 trace name context forever,level 12';
variable bind1 number;
exec :bind1 := 10;
your-query
alter session set events '10046 trace name context off';
Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
SELECT plan_table_output
FROM v$sql s,
table(dbms_xplan.display_cursor(s.sql_id,
s.child_number, 'basic+PEEKED_BINDS')) t
WHERE s.sql_text like 'select statement%';
Well the way it works is it peeks the variable the first time you declare it and from next time onwards even if you change the variable the initial plan which was cached will be used.
its necessary that the variable is set the first time.
Can we do the tracing without declaring the bind variables in the query? I know this sounds absurd! Still wanted to double check!!
TIA.
No You cannot do the tracing without declaring the bind variables because for tracing the query execution you need to execute the query for which a value needs to binded to the query
if you are interested in the plan then you can use dbms_xplan
Bookmarks