Wednesday, 14 May 2014

How to find the bind variable values of the SQL statement using SQLID?

Try this simple script:



SELECT sql_id,
  b.name BIND_NAME,
  b.value_string BIND_STRING
  from gv$sql t
JOIN gv$sql_bind_capture b USING (sql_id)
WHERE b.value_string IS NOT NULL
AND sql_id            ='&SQLID';


Additional script which may be helpful at later point of time:


To know the last executed query in the oracle and its hash value,sqlid


SELECT * FROM v$SQLTEXT_WITH_NEWLINES WHERE address =
  (SELECT prev_sql_addr FROM v$session WHERE audsid = userenv('SESSIONID'))
ORDER BY piece;

To know the SQL plan history of a sql using the sqlid:

select * from TABLE(DBMS_XPLAN.DISPLAY_AWR('&sqlid'));

No comments:

Post a Comment