zoukankan      html  css  js  c++  java
  • 如何分析存储过程中Sql语句(Oracle 9i\Windows)

       Oracle中如何分析存储过程中的sql语句?先看看如何分析语句吧。
        在Oracle工具中找的分析工具:Oracle-OraHome90->Enterprise Management Packs->Tuning->Sql Analyze
        开始登陆:
     

     
       开始查询分析吧。首先来个最简单的,类似于hello word!
        selece count(*)  from t_atzb; 不错执行完毕,并出现相应的统计信息。
     
       不过偶的很多算法在存储过程中呢,如何执行呀?先将存储过程中的Sql语句挑出一些来分析一下。
       第一个:
    insert into T_QB192_168_0_52 (F_TPBH,F_FQXXBH,F_TZWZBH,F_UPTIME,F_FEATURE) 
      
    select t_atzb.F_tpbh,F_FQXXBH,F_TZWZBH,F_UPTIME,       F_FEATURE_DISPERSION(f_bSpatial0,f_bSpatial1,f_bSpatial2,f_bSpatial3,f_bSpatial4,f_bSpatial5,f_bSpatial6,
          
    8936,494300,2695000,158200000,99580000,886300000,31650000000) v_Feature 
       
    from
       t_atzb 
    inner join t_atpb inner join t_ab on t_atpb.f_bh=t_ab.f_bh on t_atzb.f_tpbh =t_atpb.f_tpbh 
       
    where t_atzb.F_TPBH <>'210200200610000101';

        其中凡F_FEATURE_DISPERSION是自定义的一个函数。所以执行时发生错误:
    出现错误在 gmjora.es 上:

    XP
    -21016: 出现数据库错误:

    /* OracleOEM */ EXPLAIN PLAN SET statement_id = 'VMQ: 18899' INTO plan_table FOR SELECT t_atzb.f_tpbh, f_fqxxbh, f_tzwzbh, f_uptime, 
           F_FEATURE_DISPERSION(f_bspatial0, f_bspatial1, f_bspatial2, f_bspatial3, 
           f_bspatial4, f_bspatial5, f_bspatial6, 
    89364943002695000158200000
           
    9958000088630000031650000000

    ORA
    -00904: 鏃犳晥鍒楀悕


      原因:      试图访问 Oracle Expert 服务资料档案库或可优化的目
                 标数据库时出现服务器错误。错误文本提供具体的
                 Oracle Server 错误消息。

      操作:      如果错误中指明了一个环境问题 (例如: 例程未启动),
                 请解决该问题。

    还出现乱码了,总之不能分析了吧,不知道还有什么方法?


    在网上搜搜,试试这个吧:在SqlPlus中分析Sql语句。
    1>打开D:\oracle\ora90\sqlplus\admin\plustrce.sql文件
    后复制以下几句话:
    drop role plustrace;
    create role plustrace;

    grant select on v_$sesstat to plustrace;
    grant select on v_$statname to plustrace;
    grant select on v_$session to plustrace;
    grant plustrace to dba with admin option;
    2>以sys用户登陆SqlPlus,并执行以上语句(以前没有plustrace的话drop时会提示错误,没有关系)。
    3>将产生的plustrace角色赋予一般用户bmrsauto.
    grant plustrace to bmrsauto;
    4>打开文件:D:\oracle\ora90\rdbms\admin\utlxplan.sql
    复制该创建表语句:
    create table PLAN_TABLE (
        statement_id     
    varchar2(30),
        
    timestamp        date,
        remarks          
    varchar2(80),
        operation        
    varchar2(30),
        options           
    varchar2(255),
        object_node      
    varchar2(128),
        object_owner     
    varchar2(30),
        
    object_name      varchar2(30),
        object_instance numeric,
        object_type     
    varchar2(30),
        optimizer       
    varchar2(255),
        search_columns  
    number,
        id        numeric,
        parent_id    numeric,
        position    numeric,
        cost        numeric,
        cardinality    numeric,
        bytes        numeric,
        other_tag       
    varchar2(255),
        partition_start 
    varchar2(255),
            partition_stop  
    varchar2(255),
            partition_id    numeric,
        other        
    long,
        distribution    
    varchar2(30),
        cpu_cost    numeric,
        io_cost        numeric,
        temp_space    numeric);
    5>以bmrsauto用户登陆sqlplus。粘贴该语句并执行。
    6>在sqlplus中执行代码:
    set time on                                   (说明:打开时间显示)
    set autotrace on                           (说明:打开自动分析统计,并显示SQL语句的运行结果)
    set autotrace traceonly                 (说明:打开自动分析统计,不显示SQL语句的运行结果)

    不错吧,可以分析含有存储过程的sql语句了。

    参考网站:http://fengyu.china.com/plan.htm



  • 相关阅读:
    第十四周课程总结&实验报告
    第十三周学习总结&实验报告(八)
    第十二周学习总结
    第十一周课程总结
    第十周课程总结
    实验报告(七)&第九周课程总结
    软件工程作业02
    第一周博客作业
    2019春总结作业
    第十二周作业
  • 原文地址:https://www.cnblogs.com/xinyuxin912/p/538885.html
Copyright © 2011-2022 走看看