在一个灾备项目中,需要统计一下数据库空间占用情况。
DB2的相关操作详情解释请看:DB2数据库空间使用率统计案例
自己总结了一些Oracle相关的统计语句如下:
查看数据库大小:
select to_char(sysdate,'yyyymmdd') tjsj, dbsize||'GB' dbsize,(dbsize - freesize)||'GB' usedsize, (dbsize - freesize - indexsize)||'GB' tablesize,indexsize||'GB' indexsize from (select round(sum(bytes)/1024/1024/1024) as dbsize from dba_data_files),(select round(sum(bytes)/1024/1024/1024) as freesize from dba_free_space),(select round(sum(bytes)/1024/1024/1024) as indexsize from dba_segments where segment_type like '%INDEX%');
查看数据表总量:
select 'TABLE',sum(1) from user_objects where object_type='TABLE';
查看重做日志大小:
select group#, bytes, status from v$log;
查看归档日志大小:
select sum(a.BLOCK_SIZE*a.BLOCKS)/1024/1024 MB from v$archived_log a where a.DELETED='NO';
查看追加日志:
select supplemental_log_data_min from v$database;
查看归档日志大小及使用情况:
select * from v$recovery_file_dest
示例:
SQL>
select * from v$recovery_file_dest;
NAME SPACE_LIMIT SPACE_USED SPACE_RECLAIMABLE NUMBER_OF_FILES
----------- ---------- ----------------- ---------------
/u03/fast_recovery_area 8589934592 6551817216
SQL>
select * from v$flash_recovery_area_usage;
FILE_TYPE PERCENT_SPACE_USED PERCENT_SPACE_RECLAIMABLE NUMBER_OF_FILES
------------ ------------------ ------------------------- ---------------
CONTROL FILE 0 0 0
REDO LOG 1.83 0 3
ARCHIVED LOG 74.44 0 159
如果 ARCHIVED LOG 超过90% oracle随时有宕机的危险,为了避免因为空间满导致的当即问题,可以考虑增加归档日志存放空间的方案,
增大归档日志空间语句:
SQL>
alter system set db_recovery_file_dest_size=30G; ------------增加的空间应根据现有的可用空间和历史增长率去估计。
System altered.
阅读(5770) | 评论(0) | 转发(0) |