手机版
你好,游客 登录 注册
背景:
阅读新闻

Oracle SQL 执行计划和分析小结

[日期:2014-06-04] 来源:Linux社区  作者:jdk2006 [字体:大 中 小]

执行脚本:

C:\Users\Administrator>sqlplus sys/bosft@LOCAL as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on 星期三 6月 4 10:36:33 2014
Copyright (c) 1982, 2010, Oracle.  All rights reserved.
连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> @J:\oracle11\product\11.2.0\dbhome_1\sqlplus\admin\plustrce.sql
SQL> drop role plustrace;
角色已删除。

SQL> create role plustrace;
角色已创建。

SQL> grant select on v_$sesstat to plustrace;
授权成功。

SQL> grant select on v_$statname to plustrace;
授权成功。

SQL> grant select on v_$mystat to plustrace;
授权成功。

SQL> grant plustrace to dba with admin option;
授权成功。

SQL> set echo off
SQL> grant plustrace to bsoft_ypjg;--授权给
授权成功。

2、使用AutoTrace进行SQL执行计划分析

SQL> show pagesize        查看SQL*Plus页面显示的总行数
pagesize 14
SQL> set pagesize 100;    设置SQL*Plus页面显示的总行数

SQL> show linesize        查看SQL*Plus行显示的总字符数
linesize 80
SQL> set linesize 500;    设置SQL*Plus行显示的总字符数

SQL> set timing on        设置打印sql语句的运行时间
SQL> set autotrace on    开启AutoTrace,显示AutoTrace信息和执行结果
SQL> select count(1) from dual;

  COUNT(1)
----------
        1

已用时间:  00: 00: 00.01

执行计划
----------------------------------------------------------
Plan hash value: 3910148636

-----------------------------------------------------------------
| Id  | Operation        | Name | Rows  | Cost (%CPU)| Time    |
-----------------------------------------------------------------
|  0 | SELECT STATEMENT |      |    1 |    2  (0)| 00:00:01 |
|  1 |  SORT AGGREGATE  |      |    1 |            |          |
|  2 |  FAST DUAL      |      |    1 |    2  (0)| 00:00:01 |
-----------------------------------------------------------------

统计信息
----------------------------------------------------------
          1  recursive calls
          0  db block gets
          0  consistent gets
          0  physical reads
          0  redo size
        423  bytes sent via SQL*Net to client
        415  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
          1  rows processed

更多Oracle相关信息见Oracle 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=12

本文永久更新链接地址:http://www.linuxidc.com/Linux/2014-06/102689.htm

linux
相关资讯       Oracle SQL  Oracle SQL执行计划 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款