檢查oracle資料庫資料完整度

2021-07-26 08:26:11 字數 1024 閱讀 2451

1、檢視表空間總大小,剩餘大小,使用大小

select df.tablespace_name,sum(df.bytes)/1024/1024 total,sum(fs.bytes)/1024/1024 free,sum(df.bytes-fs.bytes)/1024/1024 used from dba_data_files df,dba_free_space fs

where df.tablespace_name = fs.tablespace_name

group by df.tablespace_name

2、檢視使用者下每種物件的個數

select owner,object_type,count(1) from all_objects where owner='username' group by owner,object_type 

3檢視行數大小(有時統計不出來,最好對比匯入匯出日誌,裡面會記錄匯入匯出的條數)

select table_name,num_rows from dba_all_tables where tablespace_name='tablespace' 

4檢視某種物件的詳情列表

(1) 檢視索引

select object_name  from all_objects where object_type='index' and owner='username';

(2) 檢視序列

select object_name  from all_objects where object_type='sequence' and owner='username';

(3) 檢視job

select object_name  from all_objects where object_type='job' and owner='username';

(4) 檢視trigger

select object_name  from all_objects where object_type='trigger' and owner='username';

資料庫完整性檢查

為了主動發現資料庫側頁損壞,保證資料庫邏輯和物理完整性,計畫每週六上午 6點,針對生產主庫上的所有系統和使用者資料庫執行 dbcc checkdb 將結果記錄到表中。以下為理論依據 sql server 資料庫可以檢測出頁損壞,此時,具體的表現形式可能為下述三種錯誤的一種 sql server 發現...

資料庫完整性定義與檢查

在列級定義實體完整性 在表級定義實體完整性 create table sc sno char 9 cno char 4 grade smallint,primary key sno,cno foreign key sno references student sno foreign key cno ...

檢查Oracle資料庫和PDB資料庫的大小

檢查oracle資料庫和pdb資料庫的大小 non cdb資料庫的以下查詢 檢查磁碟上資料庫消耗的物理消耗量。select sum bytes 1024 1024 size in mb from dba data files 檢查資料使用的總空間。select sum bytes 1024 1024...