我不是Oracle的专家刚开始工作。当我执行以下查询时,它以|
(管道)格式输出。我希望在EXPLAIN PLAN
或tabluar
或json
中输出xml
等等...是否可能?
EXPLAIN PLAN FOR SELECT * FROM user_master;
SELECT plan_table_output FROM TABLE(DBMS_XPLAN.DISPLAY('plan_table'));
Output:
Plan hash value: 3060894046
---------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
---------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 94 | 2 (0)| 00:00:01 |
| 1 | TABLE ACCESS FULL| USER_MASTER | 1 | 94 | 2 (0)| 00:00:01 |
---------------------------------------------------------------------------------
答案 0 :(得分:3)
如果直接访问PLAN_TABLE
,您可以以表格格式获取它:
select plan_id,
operation,
options,
cost,
cpu_cost,
io_cost,
temp_space,
access_predicates,
bytes,
object_name,
object_alias,
optimizer,
object_type
from plan_table
start with parent_id is null
connect by prior id = parent_id;
由于plan_table可以包含不同的计划,因此使用显式语句ID可能更好:
explain plan
set statement_id = 'foo'
for
select ...;
然后在plan_table上的select中使用它:
select ....
from plan_table
start with parent_id is null and statement_id = 'foo'
connect by prior id = parent_id;
要将此作为XML使用,您可以使用:
select dbms_xplan.display_plan(type => 'xml')
FROM dual