ORACLE应用经验(2)

来源:asp之家 时间:2010-07-31 13:31:00 

 ------谁正在访问数据库?
Select c.sid, c.serial#,c.username,a.object_id,b.object_name,
c.program,c.status,d.name,c.osuser
from v$Locked_object a,
All_objects b,
v$session c,
audit_actions d
where a.object_id=b.object_id
and a.session_id =c.sid(+)
and c.command=d.action;


alter system kill session &1,&2;

Select a.sid,a.serial#,a.username,a.status,a.program,b.name,a.osuser
from v$session a,audit_actions b
where a.command=b.action
And username=&1;
------谁被锁住?
Select a.sid,a.serial#,a.username,A.LOCKWAIT,a.status,a.program,b.name
from v$session a,audit_actions b
where a.command=b.action
AND LOCKWAIT IS NOT NULL;
------谁在锁表?
Select a.sid,a.serial#,a.username,A.LOCKWAIT,a.status,a.program,b.name
from v$session a,audit_actions b
where a.command=b.action
AND STATUS=ACTIVE;

Select sid, serial#, object_name, row_wait_block#,
row_wait_row#, row_wait_file#
from all_objects, v$session
where row_wait_obj#=object_id and type=USER
and lockwait is not null ;

Select sl.username, sl.sid, sl.serial#
from v_$lock l1, v$session s1
where exists (select * from v_$lock l2, v$session s2
where l2.sid=s2.sid and l2.id1=l1
and s2.lockwait=l2.kaddr
and request=0
and l1.sid=s1.sid) ;

select count(*) from v$session;
select count(*) from sys.v_$process;
select count(*) from sys.v_$transaction;

ZYP_35.98

------查看哪些包要固定
COLUMN OWNER FORMAT A10
Select owner, name, type,
source_size+code_size+parsed_size+error_size BYPES
from dba_object_size
where type=PACKAGE BODY ORDER BY 4 DESC ;

------查看一个用户拥有哪些表空间的实体信息:
Select tablespace_name, owner, segment_name,segment_type
from dba_segments
where owner-SyS
and segment_type_-ROLLBACK
order by tablespace_name, owner, segment_name ;

break on owner on segment_name
COLUMN segment_name FORMAT A15
cOLUMN tablespace_name FORMAT A15
COLUMN file_name FORMAT A20
SELECT A.owner, a.segment_name, b.tablespace_name, b.file_name,
sum(a.bytes) bytes
from dba_extents a, dba_data_files b
where a.file_id-b.file_id group by a.owner, a.segment_name,
b.tablespace_name, b.file_name ;

------看内存缓冲区使用效率的指数是命中率HITS:
Hits=Logical_reads/(logical_reads+physical_reads)
其中:logical_reads=db_block_gets+consistent_reads

select cur.value db, con.value con, phy.value phy,
(cur.value+con.value)/cur.value+con.value+phy.value)*100 HITS
from v$sysstat cur, v$sysstat con, v$sysstat phy
where CUR.NAME=db block gets AND
CON.NAME=consistent gets AND
PHY.NAME=physical reads ;

------如何检测ROLLBACK SEGMENT竞争?
select class, count from v$waitstat
where class in
(system undo header, system undo block,
undo header, undo block) ;

select sum(value) from v$sysstat where name in
(db block gets, consistents gets) ;

若count/sum(value)大于1%,则应考虑增加ROLLBACK SEGMENT

------查看有事务在哪几个回退段中:
COLUMN u FORMAT A15
COLUMN s FORMAT A15
COLUMN s FORMAT A80
select osuser o, username u, segment_name s, sa.sql_text
from v$session s, v$transaction t, dba_rollback_segs r, v$sqlarea sa
where s.taddr=t.addr and t.sidusn=r.segmant_id(+)
and s.sql_address=sa.address(+) ;

标签:oracle,经验
0
投稿

猜你喜欢

  • Python爬虫使用脚本登录Github并查看信息

    2022-05-02 13:09:28
  • MySQL中VARCHAR与CHAR格式数据的区别

    2024-01-15 01:58:25
  • Appium自动化测试中获取Toast信息操作

    2022-05-12 07:10:48
  • 详解Python中dict与set的使用

    2022-09-11 05:22:22
  • Pyinstaller打包工具的使用以及避坑

    2023-11-07 18:50:59
  • Python二进制串转换为通用字符串的方法

    2022-09-30 19:36:11
  • Jupyter notebook运行后打不开网页的问题解决

    2021-07-10 01:35:30
  • python工具dtreeviz决策树可视化和模型可解释性

    2023-01-12 03:46:55
  • Python Scrapy多页数据爬取实现过程解析

    2021-02-28 08:14:01
  • python 产生token及token验证的方法

    2023-05-19 17:25:13
  • MySQL中B树索引和B+树索引的区别详解

    2024-01-19 12:07:57
  • Python里的dict和set的背后小秘密

    2023-11-20 01:01:11
  • sql注入与转义的php函数代码

    2023-07-16 11:20:15
  • sqlserver 无法验证产品密匙的完美解决方案[测试通过]

    2024-01-23 11:53:23
  • asp如何让我的网页自动适应客户端的屏幕分辨率?

    2010-05-13 16:38:00
  • Python在后台自动解压各种压缩文件的实现方法

    2022-10-04 17:59:59
  • 详解Python的Django框架中inclusion_tag的使用

    2021-05-19 13:10:26
  • python爬虫框架feapder的使用简介

    2021-07-20 14:38:27
  • django获取from表单multiple-select的value和id的方法

    2021-11-03 13:13:31
  • 如何使用Git优雅的回滚实现

    2022-03-17 15:49:15
  • asp之家 网络编程 m.aspxhome.com