Oracle表變化趨勢追蹤記錄

2022-07-03 13:21:11 字數 4858 閱讀 5900

#dba_hist_seg_stat可以看出物件的使用趨勢,構造如下sql查詢出每個時間段內資料庫物件的增長量,其中db_block_changes_delta為塊個數 

select

c.snap_id,

to_char(c.end_interval_time,

'yyyy-mm-dd

') snap_time,

a.owner,

a.object_name

, a.object_type,

b.db_block_changes_delta

from

dba_objects a,

(select

snap_id, obj#, db_block_changes_delta

from

dba_hist_seg_stat

where db_block_changes_delta >

20000

order

by snap_id desc, db_block_changes_delta desc

) b,

dba_hist_snapshot c

where a.object_id

=b.obj#

and object_type =

'table

'and b.snap_id =

c.snap_id

order

bydb_block_changes_delta

#下面的sql查詢出某個時間段內,資料庫物件的變化大小,單位以換算成gb

select a.object_name

, to_char(c.end_interval_time,

'yyyy-mm-dd

') snap_time,

sum(b.db_block_changes_delta) /

1024

/1024

gb

from

dba_objects a,

(select

snap_id, obj#, db_block_changes_delta

from

dba_hist_seg_stat

where db_block_changes_delta >

20000

order

by snap_id desc, db_block_changes_delta desc

) b,

dba_hist_snapshot c

where a.object_id

=b.obj#

and object_type =

'table

'and b.snap_id =

c.snap_id

group

by a.object_name

, c.end_interval_time

order

bygb

簡單介紹下dba_hist_seg_stat 。dba_hist_seg_stat檢視內記錄了資料庫例項啟動以來段的變化資訊,該檢視的資料來自於v$segstat 

column datatype null description

snap_id number unique snapshot id

dbid number database id for the snapshot

instance_number number instance number for the snapshot

ts# number tablespace number

obj# number dictionary object number

dataobj# number data object number

logical_reads_total number cumulative value for logical reads

logical_reads_delta number delta value for logical reads

buffer_busy_waits_total number cumulative value for buffer busy waits

buffer_busy_waits_delta number delta value for buffer busy waits

db_block_changes_total number cumulative value for db block changes

db_block_changes_delta number delta value for db block changes

physical_reads_total number cumulative value for physical reads

physical_reads_delta number delta value for physical reads

physical_writes_total number cumulative value for physical writes

physical_writes_delta number delta value for physical writes

physical_reads_direct_total number cumulative value for physical reads direct

physical_reads_direct_delta number delta value for physical reads direct

physical_writes_direct_total number cumulative value for physical writes direct

physical_writes_direct_delta number delta value for physical writes direct

itl_waits_total number cumulative value for itl waits

itl_waits_delta number delta value for itl waits

row_lock_waits_total number cumulative value for row lock waits

row_lock_waits_delta number delta value for row lock waits

gc_cr_blocks_served_total number cumulative value for global cache cr blocks served

gc_cr_blocks_served_delta number delta value for global cache cr blocks served

gc_cu_blocks_served_total number cumulative value for global cache current blocks served

gc_cu_blocks_served_delta number delta value for global cache current blocks served

gc_buffer_busy_total number cumulative value for global cache buffer busy

gc_buffer_busy_delta number delta value for global cache buffer busy

gc_cr_blocks_received_total number cumulative value for global cache cr blocks received

gc_cr_blocks_received_delta number delta value for global cache cr blocks received

gc_cu_blocks_received_total number cumulative value for global cache current blocks received

gc_cu_blocks_received_delta number delta value for global cache current blocks received

space_used_total number cumulative value for space used

space_used_delta number delta value for space used

space_allocated_total number cumulative value for space allocated

space_allocated_delta number delta value for space allocated

table_scans_total number cumulative value for table scans

table_scans_delta number delta value for table scans

Oracle 表空間記錄

select from dba tables where tablespace name digitparty 所有表 digitparty為表空間名稱,區分大小寫 select from user tables 檢視所有表 select from all views where owner dig...

T SQL 如何檢查並記錄表資料變化

有時候 我們需要記錄一下表資料的操作記錄,再根據操作記錄處理一下邏輯,這種情況下,可以通過t sql中的output子句簡單處理.定義測試表變數 declare t table id int primary key identity,name nvarchar 100 匯入測試資料 insert i...

oracle 查詢表的操作記錄

1,檢視某一時間的執行過的所有sql select t.sql text,t.first load time from v sqlarea t where t.first load time like 2019 01 28 order by t.first load time desc 2019 0...