在進行 SQL STATEMENT的相關優化與效能問題,常常需要先查詢某STATEMENT的SQL ID
SELECT /* MY SQL */ * FROM dual; SELECT sql_id, plan_hash_value, substr(sql_text,1,40) sql_text FROM v$sql WHERE sql_text like 'SELECT /* MY SQL */%'若是 SQL 區塊,則參考 DocID :Doc ID 741724.1
declare v1 number; begin select /* CountTest */ count(*) into v1 from invalid_objects; end; /然後用下列方式查詢SQL ID
SQL> select sql_id, sql_text from v$sql where sql_text like '%CountTest%'; /