Oracle-11g-R2

如何為以下查詢創建解釋計劃?我收到 ORA-00900:無效的 SQL 語句錯誤

  • January 23, 2019

我在嘗試時收到 ORA-00900: invalid SQL statement 錯誤。但 sql 查詢執行良好,無需解釋。

詢問:create or replace view TaskView as select T1.PersonID,T2.ID ,T2.Task from Table1 T1,Table2 T2 where T1.TaskID=T2.ID;

錯誤

CREATE VIEW 語句沒有執行計劃,因為在創建視圖時不會評估 SELECT。您需要先創建視圖,然後使用視圖對查詢執行 EXPLAIN:

create or replace view TaskView 
as
select T1.PersonID,T2.ID ,T2.Task 
from Table1 T1,Table2 T2
where T1.TaskID=T2.ID;

然後

explain plan 
 set statement_id = 'TASK'
select *
from taskview;

或簡單地解釋底層查詢:

explain plan 
 set statement_id = 'TASK'
select T1.PersonID,T2.ID ,T2.Task 
from Table1 T1,Table2 T2
where T1.TaskID=T2.ID;

引用自:https://dba.stackexchange.com/questions/227828