您好,欢迎访问一九零五行业门户网

oracle日常诊断语句

欢迎进入oracle社区论坛,与200万技术人员互动交流 >>进入 18. 清除已删除的arch log 信息 crosscheck archivelog all; delete expired archivelog all; ――――――――――――――――――――――――――――――――――――――――――――――――
欢迎进入oracle社区论坛,与200万技术人员互动交流 >>进入
    18. 清除已删除的arch log 信息
    crosscheck archivelog all;
    delete expired archivelog all;
    ――――――――――――――――――――――――――――――――――――――――――――――――
    19。查找等待时间最长的语句
    select a.username,a.osuser,a.process,a.machine,a.action,a.sid, a.last_call_et ,b.sql_text
    from v$session a
    ,v$sqltext b
    where a.username is not null
    and   a.status = 'active'
    and   a.sql_address = b.address
    order by a.last_call_et,a.sid,b.piece ;
    根据查出来的sid判断等待的对象
    select owner,segment_name,segment_type
    from (select p1 file#, p2 block# from  v$session_wait
    where sid = 284
    and event in ('buffer busy waits'
    ,'db file sequential read'
    ,'db file scattered read'
    ,'free buffer waits')) b
    ,dba_extents a
    where a.file_id = b.file#
    and   b.block# between a.block_id and (a.block_id+blocks-1);
    ――――――――――――――――――――――――――――――――――――――――――――――――
    20. 监控索引使用
    select * from v$object_usage where used='yes'
    select * from v$object_usage where used='no'
    select 'alter index '||index_name||' monitoring usage;' from dba_indexes where owner='absys';
    ――――――――――――――――――――――――――――――――――――――――――――――――
    21. 查找正在执行的存储过程
    create or replace procedure sys.who_is_using(obj_name varchar2) is
    begin
    dbms_output.enable(1000000);
    for i in (select distinct b.username,b.sid
    from sys.x$kglpn a,v$session b,sys.x$kglob c
    where a.kglpnuse = b.saddr
    and upper(c.kglnaobj)  like upper(obj_name)
    and a.kglpnhdl = c.kglhdadr)
    loop
    dbms_output.put_line('('||to_char(i.sid)||') - '||i.username);
    end loop;
    end;
    ――――――――――――――――――――――――――――――――――――――――――――――――
    22.查找全表扫描的sql语句
    select sql_text from v$sqltext t, v$sql_plan p
    where t.hash_value=p.hash_value
    and p.operation='index'
    and p.options='full scan'
    order by p.hash_value, t.piece;
    查找fast full index 扫描的sql语句可以这样;
    select sql_text from v$sqltext t, v$sql_plan p
    where t.hash_value=p.hash_value
    and p.operation='index'
    and p.options='full scan'
    order by p.hash_value, t.piece;
    ――――――――――――――――――――――――――――――――――――――――――――――――
    23.已经alter system kill session 但是没有kill干净,查找进程号
    select p.addr from v$process p where pid 1
    minus
    select s.paddr from v$session s;
    ――――――――――――――――――――――――――――――――――――――――――――――――
    24.10g自动收集数据
    select job_name,enabled,state from dba_scheduler_jobs;
    exec dbms_scheduler.disable('gather_stats_job');
    exec dbms_scheduler.enable('gather_stats_job');
    ――――――――――――――――――――――――――――――――――――――――――――――――
    25.查询有enqueue等待的事件
    select   b.sid, b.serial#, b.username, machine, event, wait_time,
    chr (bitand (p1, -16777216) / 16777215)
    || chr (bitand (p1, 16711680) / 65535) enqueue type
    from v$session_wait a, v$session b
    where a.event not like 'sql*n%'
    and a.event not like 'rdbms%'
    and a.sid = b.sid
    and b.sid > 8
    and a.event = 'enqueue'
    order by username;
    ――――――――――――――――――――――――――――――――――――――――――――――――
    26.如何确定哪个表空间读写频繁?
    select name,phyrds,phywrts,readtim,writetim
    from v$filestat a,v$dbfile b
    where a.file# = b.file#
    order by readtim desc
    ――――――――――――――――――――――――――――――――――――――――――――――――
    27.在磁盘上的物理写入和读取次数上如果出现很大的差别,就表明肯定有哪个磁盘负载过多!
    如果出现磁盘负载不平衡,可以通过移动数据文件来均衡文件i/o:
    alter tablespace tablespace_name offline;
    $cp /disk1/a.dbf /disk2/a.dbf;
    alter tablespace tablespace_name rename datafile ‘/disk1/a.dbf’ to ‘/disk2/a.dbf’;
    alter tablespace tablespace online;
    $rm /disk1/a.dbf
    ――――――――――――――――――――――――――――――――――――――――――――――――
    28. 查询sql语句执行时,硬语法分析的次数
    select name,value
    from v$sysstat
    where name like ‘parse count%’;
    ――――――――――――――――――――――――――――――――――――――――――――――――
    29.查询sql语句中没有帮定变量的sql语句,按执行次数排序
    select substr (sql_text, 1, 40) “sql”, count (*),
    sum (executions) “totexecs” from v$sqlarea where executions
    group by substr (sql_text, 1, 40) having count (*) > 20 order by 2;
    ――――――――――――――――――――――――――――――――――――――――――――――――
    30.该项显示buffer cache大小是否合适
    公式:1-((physical reads-physical reads direct-physical reads direct (lob)) / session logical reads)
    执行:
    select 1-((a.value-b.value-c.value)/d.value)
    from v$sysstat a,v$sysstat b,v$sysstat c,v$sysstat d
    where a.name=’physical reads’ and
    b.name=’physical reads direct’ and
    c.name=’physical r
  [1] [2]
其它类似信息

推荐信息