ORACLE應用經驗(2)(轉)
ORACLE應用經驗(2)[@more@]------誰正在訪問資料庫?
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(+) ;
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(+) ;
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9417382/viewspace-938090/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- GitHub CSP應用的經驗分享Github
- 如何改善應用啟動效能 | Facebook 應用的經驗分享
- Oracle實驗(02):轉換 & 轉譯Oracle
- 後端應用分層經驗總結後端
- 淺談AB實驗及其在轉轉B2B報價系統中的應用
- Serverless 應用開發的 7 個經驗心得Server
- Hulu大資料架構與應用經驗大資料架構
- 充電樁定期檢測應用經驗有哪些?
- Java 應用壓測效能問題定位經驗分享Java
- OS課 Level 2 實驗(2):軟體的部署與應用
- 2Gb - File limits in Oracle(轉)MITOracle
- Oracle long轉為varchar2Oracle
- Native轉型Flutter經驗分享Flutter
- 用WSL2+Docker Desktop部署InLong的坑和經驗Docker
- Oracle insert大量資料經驗之談Oracle
- docker使用經驗總結(三、Docker compose基礎應用)Docker
- 安卓應用效能除錯和優化經驗分享安卓除錯優化
- Spring Boot之驗證模組應用總結2Spring Boot
- 實用的管理經驗
- 實驗3 轉移指令跳轉原理及其簡單應用程式設計程式設計
- iOS開發經驗總結2iOS
- 轉載-知乎工作後的經驗
- 阿里巴巴的 Kubernetes 應用管理實踐經驗與教訓阿里
- 線上高併發應用重構(寫)填坑經驗分享(二)
- 線上高併發應用重構(寫)填坑經驗分享(一)
- 微信群控系統的應用和實戰經驗分享
- Android開發者峰會:Android應用效能優化經驗分享Android優化
- Oracle 12CR2查詢轉換之星型轉換Oracle
- Oracle Tuning (Oracle 效能調整)的一些總結(轉)2Oracle
- 十、特殊應用:人臉識別和神經風格轉換
- One-on-One Oracle閱讀筆記2(轉)Oracle筆記
- Omi應用md2site釋出-markdown轉網站利器網站
- oracle資料庫開發的一些經驗Oracle資料庫
- 快應用初體驗
- 2 開始實用 Oracle Data GuardOracle
- 眾多行業客戶採用Oracle管理雲提升使用者體驗和交付應用程式行業Oracle
- Netflix採用GraphQL的經驗分享
- 用Servlet校驗密碼2Servlet密碼
- java的應用2Java