UNDO相關查詢
1. undo 相關檢視
dba_rollback_segs
dba_undo_extents
v$transaction
v$rollstat
v$rollname
v$undostat
x$ktuxe
2. 檢視 undo 相關引數
select name,value,issys_modifiable from v$parameter where name like '%undo%';
show parameter undo
3. 檢視所有 undo 表空間與資料檔案
select tablespace_name,status,retention from dba_tablespaces where contents='UNDO';
select file_name,bytes from dba_data_files where tablespace_name like '%UNDO%';
4. 檢視所有回滾段/區/塊資訊及狀態資訊
select * from v$rollname;
select owner,segment_name,tablespace_name from dba_rollback_segs;
select usn,xacts,rssize,hwmsize,shrinks from v$rollstat order by usn;
select extent_id,bytes,status from dba_undo_extents where segment_name='_SYSSMU1$';
select segment_name,tablespace_name,extent_id,file_id,block_id,blocks from dba_extents where segment_name='_SYSSMU1$';
select segment_name,blocks,extents from dba_segments where segment_name='_SYSSMU1$';
select a.name,b.xacts,b.writes,b.extents from v$rollname a,v$rollstat b where a.usn=b.usn;
5. 檢視事務對應的回滾資訊
select xid,xidusn,xidslot,xidsqn,ubafil,ubablk from v$transaction;
dba_rollback_segs
dba_undo_extents
v$transaction
v$rollstat
v$rollname
v$undostat
x$ktuxe
2. 檢視 undo 相關引數
select name,value,issys_modifiable from v$parameter where name like '%undo%';
show parameter undo
3. 檢視所有 undo 表空間與資料檔案
select tablespace_name,status,retention from dba_tablespaces where contents='UNDO';
select file_name,bytes from dba_data_files where tablespace_name like '%UNDO%';
4. 檢視所有回滾段/區/塊資訊及狀態資訊
select * from v$rollname;
select owner,segment_name,tablespace_name from dba_rollback_segs;
select usn,xacts,rssize,hwmsize,shrinks from v$rollstat order by usn;
select extent_id,bytes,status from dba_undo_extents where segment_name='_SYSSMU1$';
select segment_name,tablespace_name,extent_id,file_id,block_id,blocks from dba_extents where segment_name='_SYSSMU1$';
select segment_name,blocks,extents from dba_segments where segment_name='_SYSSMU1$';
select a.name,b.xacts,b.writes,b.extents from v$rollname a,v$rollstat b where a.usn=b.usn;
5. 檢視事務對應的回滾資訊
select xid,xidusn,xidslot,xidsqn,ubafil,ubablk from v$transaction;
Transaction ID (XID) = Undo segment No. + Slot No. + Sequence No.
undo 段頭塊的 trace 檔案中和資料字典中均以 16 進位制形式出現
事務表資訊
select xid,xidusn,xidslot,xidsqn from v$transaction;
XID XIDUSN XIDSLOT XIDSQN
---------------- ---------- ---------- ----------
050022005A010000 5 34 346
轉換規則
1. 050022005A010000 = 0500.2200.5A010000
2. 再做高低位互換,0500 => 0005, 2200 => 0022, 5A010000 => 0000015A
3. 獲得XID = 0005.0022.0000015A, 這跟 undo header block 中記錄的 xid 就完全一樣
透過 sql 轉換
select
to_number(substr(xid,3,2)||substr(xid, 1,2),'xxxxxxxxxxxx') xidusn,
to_number(substr(xid,7,2)||substr(xid, 5,2),'xxxxxxxxxxxx') xidslot,
to_number(substr(xid,15,2)||substr(xid,13,2)||substr(xid,11,2)||substr(xid,9,2),'xxxxxxxxxxxx') xidsqn
from (select '050022005A010000' xid from dual);
6. 檢視事務表資訊
select indx,ktuxesta,ktuxecfl,ktuxesqn wrap#,ktuxescnw scnw,ktuxescnb scnb,ktuxerdbf dba_file,ktuxerdbb dba_block,ktuxesiz nub from x$ktuxe where ktuxeusn = 9 and ktuxeslt <= 5;
7. 檢視/轉儲回滾段塊
select header_block,header_file from dba_segments where segment_name='_SYSSMU1$';
alter system dump undo header '_SYSSMU1$';
alter system dump datafile 5 block 4308;
select spid from v$process where addr in (select paddr from v$session where sid=(select sid from v$mystat where rownum=1));
8. 檢視哪個使用者正在使用回滾段的資源
select s.username,u.name from v$transaction t,v$rollstat r,v$rollname u,v$session s where s.taddr=t.addr and t.xidusn=r.usn and r.usn=u.usn order by s.username;
select a.username, b.name, c.used_ublk from v$session a, v$rollname b, v$transaction c where a.saddr=c.ses_addr and b.usn=c.xidusn and a.username='SYS';
9. 檢視 UNDO 表空間統計資訊
# 10 分鐘自動收集一次
select to_char(begin_time,'hh24:mi:ss') begin_time,to_char(end_time,'hh24:mi:ss') end_time,undoblks from v$undostat;
10. 設定 guarantee
alter tablespace undotbs1 retention guarantee;
alter tablespace undotbs1 retention noguarantee;
select tablespace_name,retention from dba_tablespaces where contents='UNDO';
11. 檢視 IMU 資訊
select * from v$sysstat where name like '%IMU%';
undo 段頭塊的 trace 檔案中和資料字典中均以 16 進位制形式出現
事務表資訊
select xid,xidusn,xidslot,xidsqn from v$transaction;
XID XIDUSN XIDSLOT XIDSQN
---------------- ---------- ---------- ----------
050022005A010000 5 34 346
轉換規則
1. 050022005A010000 = 0500.2200.5A010000
2. 再做高低位互換,0500 => 0005, 2200 => 0022, 5A010000 => 0000015A
3. 獲得XID = 0005.0022.0000015A, 這跟 undo header block 中記錄的 xid 就完全一樣
透過 sql 轉換
select
to_number(substr(xid,3,2)||substr(xid, 1,2),'xxxxxxxxxxxx') xidusn,
to_number(substr(xid,7,2)||substr(xid, 5,2),'xxxxxxxxxxxx') xidslot,
to_number(substr(xid,15,2)||substr(xid,13,2)||substr(xid,11,2)||substr(xid,9,2),'xxxxxxxxxxxx') xidsqn
from (select '050022005A010000' xid from dual);
6. 檢視事務表資訊
select indx,ktuxesta,ktuxecfl,ktuxesqn wrap#,ktuxescnw scnw,ktuxescnb scnb,ktuxerdbf dba_file,ktuxerdbb dba_block,ktuxesiz nub from x$ktuxe where ktuxeusn = 9 and ktuxeslt <= 5;
7. 檢視/轉儲回滾段塊
select header_block,header_file from dba_segments where segment_name='_SYSSMU1$';
alter system dump undo header '_SYSSMU1$';
alter system dump datafile 5 block 4308;
select spid from v$process where addr in (select paddr from v$session where sid=(select sid from v$mystat where rownum=1));
8. 檢視哪個使用者正在使用回滾段的資源
select s.username,u.name from v$transaction t,v$rollstat r,v$rollname u,v$session s where s.taddr=t.addr and t.xidusn=r.usn and r.usn=u.usn order by s.username;
select a.username, b.name, c.used_ublk from v$session a, v$rollname b, v$transaction c where a.saddr=c.ses_addr and b.usn=c.xidusn and a.username='SYS';
9. 檢視 UNDO 表空間統計資訊
# 10 分鐘自動收集一次
select to_char(begin_time,'hh24:mi:ss') begin_time,to_char(end_time,'hh24:mi:ss') end_time,undoblks from v$undostat;
10. 設定 guarantee
alter tablespace undotbs1 retention guarantee;
alter tablespace undotbs1 retention noguarantee;
select tablespace_name,retention from dba_tablespaces where contents='UNDO';
11. 檢視 IMU 資訊
select * from v$sysstat where name like '%IMU%';
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/22558114/viewspace-1122579/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 相關子查詢&非相關子查詢概念
- CURL查詢ES相關
- MySQL 相關子查詢MySql
- 什麼是SQL 語句中相關子查詢與非相關子查詢SQL
- sql語法相關子查詢與非相關子查詢SQL
- MySQL 之慢查詢相關操作MySql
- 表空間相關查詢
- mysql 查詢undo空間MySql
- oracle 查詢誰在用undoOracle
- 閃回查詢(undo sql)SQL
- sql-server相關子查詢SQLServer
- Oracle許可權相關查詢Oracle
- [鎖機制] 鎖相關查詢
- 鎖表的相關資訊查詢
- Linux 查詢 日誌 相關命令Linux
- Oracle 表空間查詢相關sqlOracleSQL
- 查詢基表的相關檢視
- PostgreSQL並行查詢相關配置引數SQL並行
- MySQL慢查詢日誌相關設定MySql
- MS SQL SERVER索引優化相關查詢SQLServer索引優化
- Oracle查詢優化器的相關引數Oracle優化
- MySQL全面瓦解9:查詢的排序、分頁相關MySql排序
- SQL中查詢語句內的相關應用SQL
- 優化訪問相關 datetime 列的查詢優化
- MySQL查詢最佳化方案彙總(索引相關)MySql索引
- oracle10g undo tablespace相關知識Oracle
- 查詢當前執行的sql及相關內容SQL
- 兩個B1相關的SQL,訂單查詢SQL
- 【UNDO】Oracle undo表空間使用率過高,因為一個查詢Oracle
- 殺會話之查詢鎖表的物件及相關操作會話物件
- MySQL索引的最左字首原理與查詢的相關優化MySql索引優化
- 資料結構:二叉查詢樹的相關操作資料結構
- 查詢資料庫物件所屬的filegroup及相關SQL資料庫物件SQL
- Oracle undo保留時間的幾個相關引數Oracle
- 區分關聯子查詢和非關聯子查詢
- exist-in和關聯子查詢-非關聯子查詢
- Django筆記十五之in查詢及date日期相關過濾操作Django筆記
- 【ORACLE】常用物化檢視相關後設資料查詢語句Oracle