EXPLAIN作為db2的查詢計劃,一般情況下需要自己打開,可是一般都是運行db2 -tvf EXPLAIN.DDL可是我運行了很多次都是錯誤的
因為不在同一個目錄,就會有錯誤。
應該這樣寫:db2 -tvf "C:\Program Files (x86)\IBM\SQLLIB\MISC\EXPLAIN.DDL"
EXPLAIN.DDL的默認目錄在C:\Program Files (x86)\IBM\SQLLIB\MISC\下,沒在同一個目錄就會有錯誤。
但有時還是會有錯誤,實際上這句執行很多SQL,創建不少表。如果發現問題,可以刪除對應的表和索引。
vcD48cD7JvrP9ttTTprXEse3L99L9o6zK1M28PC9wPjxwPjxwcmUgY2xhc3M9"brush:sql;">db2 drop TABLE EXPLAIN_ACTUALS
db2 drop FUNCTION EXPLAIN_GET_MSGS
db2 drop INDEX PRT_I1
db2 drop INDEX MQT_I2
db2 drop INDEX MQT_I1 on ADVISE_MQT
db2 drop INDEX IDX_I2
db2 drop INDEX IDX_I1
db2 drop INDEX EXP_DIAG_DAT_I1
db2 drop INDEX OBJ_I1
db2 drop INDEX STM_I1
db2 drop INDEX PRD_I1
db2 drop INDEX ARG_I1
db2 drop INDEX STMT_I1
db2 drop TABLE ADVISE_TABLE
db2 drop TABLE ADVISE_PARTITION
db2 drop TABLE ADVISE_MQT
db2 drop TABLE ADVISE_WORKLOAD
db2 drop TABLE ADVISE_INDEX
db2 drop TABLE ADVISE_INSTANCE
db2 drop TABLE OBJECT_METRICS
db2 drop TABLE EXPLAIN_DIAGNOSTIC_DATA
db2 drop TABLE EXPLAIN_DIAGNOSTIC
db2 drop TABLE EXPLAIN_STREAM
db2 drop TABLE EXPLAIN_PREDICATE
db2 drop TABLE EXPLAIN_OPERATOR
db2 drop TABLE EXPLAIN_OBJECT
db2 drop TABLE EXPLAIN_ARGUMENT
db2 drop TABLE EXPLAIN_STATEMENT
db2 drop TABLE EXPLAIN_INSTANCE
重新創建相應的表索引,視圖
db2 -tvf "C:\Program Files (x86)\IBM\SQLLIB\MISC\EXPLAIN.DDL" >d:\22.txt