EXPLAIN PLAN
SET STATEMENT_ID = 'mystatement1' -- give your statement a meaningful ID so that we can fetch it from PLAN_TABLE using it
FOR
SELECT
*
FROM
ACTIVE_USERS;
现在,从 PLAN_TABLE 中获取执行计划
SELECT
ID,
-- LPAD(' ', LEVEL - 1) -- default format
LPAD(' ', LEVEL * 2) -- Indentation is done using this
|| OPERATION
|| ' '
|| OPTIONS
|| ' '
|| OBJECT_NAME "Operation",
OBJECT_NAME AS "Name"
FROM
PLAN_TABLE
CONNECT BY PRIOR ID = PARENT_ID
AND PRIOR STATEMENT_ID = STATEMENT_ID START WITH ID = 0
AND STATEMENT_ID = 'mystatement2'
ORDER BY
ID;
您可以使用 PLAN_TABLE 获得如下结果:
您生成执行计划的声明
现在,从 PLAN_TABLE 中获取执行计划
输出:
您可以根据需要在结果中添加更多列,也可以在上述查询中使用 LPAD 添加更多空格。
干杯!!