欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

[Oracle]查看SQL的执行计划

程序员文章站 2022-06-04 16:46:36
...

SQL SET AUTOTRACE ON SQL SELECT SYSDATE FROM DUAL; SYSDATE -------------- 26-9月-12 执行计划 ---------------------------------------------------------- ERROR:anuncaughterror in function displayhashappened;pleasecontactOracle support Please

  1. SQL> SET AUTOTRACE ON
  2. SQL> SELECT SYSDATE FROM DUAL;
  3. SYSDATE
  4. --------------
  5. 26-9月 -12
  6. 执行计划
  7. ----------------------------------------------------------
  8. ERROR: an uncaught error in function display has happened; please contact Oracle
  9. support
  10. Please provide also a DMP file of the used plan table PLAN_TABLE
  11. ORA-00904: "OTHER_TAG": 标识符无效
  12. 统计信息
  13. ----------------------------------------------------------
  14. 0 recursive calls
  15. 0 db block gets
  16. 0 consistent gets
  17. 0 physical reads
  18. 0 redo size
  19. 347 bytes sent via SQL*Net to client
  20. 338 bytes received via SQL*Net from client
  21. 2 SQL*Net roundtrips to/from client
  22. 0 sorts (memory)
  23. 0 sorts (disk)
  24. 1 rows processed


解决方法:

Need to recreate or upgrade the plan table, it is still the 8i one.
Please drop the table and run

SQL> drop table PLAN_TABLE ;

表已删除。

SQL> @C:\oracle\product\10.2.0\client_2\RDBMS\ADMIN\utlxplan.sql

表已创建。


  1. SQL> SET AUTOTRACE ON
  2. SQL> SELECT SYSDATE FROM DUAL;
  3. SYSDATE
  4. --------------
  5. 26-9月 -12
  6. 执行计划
  7. ----------------------------------------------------------
  8. Plan hash value: 1388734953
  9. -----------------------------------------------------------------
  10. | Id | Operation | Name | Rows | Cost (%CPU)| Time |
  11. -----------------------------------------------------------------
  12. | 0 | SELECT STATEMENT | | 1 | 2 (0)| 00:00:01 |
  13. | 1 | FAST DUAL | | 1 | 2 (0)| 00:00:01 |
  14. -----------------------------------------------------------------
  15. 统计信息
  16. ----------------------------------------------------------
  17. 0 recursive calls
  18. 0 db block gets
  19. 0 consistent gets
  20. 0 physical reads
  21. 0 redo size
  22. 347 bytes sent via SQL*Net to client
  23. 338 bytes received via SQL*Net from client
  24. 2 SQL*Net roundtrips to/from client
  25. 0 sorts (memory)
  26. 0 sorts (disk)
  27. 1 rows processed
  28. SQL>

ps:查看执行计划,也可以是使用 [Oracle]如何查看SQL的执行计划 - DBMS_XPLAN Package