数据文件,作为数据库存储数据的方式,其内具体的数据分布与差异是无法直观看到的。它有点像黑盒子,通常情况下,大家只知道向其中填数据、取数据,却不知道里面到底有些什么,大家都是把这些细枝末节的问题丢给了Oracle软件自己运行与管理。
在本文接下来的内容里,你可以初步的看到关于数据文件的这些信息的Summary。

查看数据文件中具有的用户以及用户下的Segment数量与大小:

代码如下:
SET ECHO OFF
SET FEEDBACK 6
SET HEADING ON
SET LINESIZE 380
SET PAGESIZE 50000
SET TERMOUT ON
SET TIMING OFF
SET TRIMOUT ON
SET TRIMSPOOL ON
SET VERIFY OFF

CLEAR COLUMNS
CLEAR BREAKS
CLEAR COMPUTES

BREAK ON report ON file_name skip 2

col file_name for a45
col owner for a23
col tablespace_name for a23

COMPUTE sum LABEL “” of OWNER_SEG_COUNTS bytes on file_name
COMPUTE sum LABEL “” of OWNER_SEG_MB bytes on file_name

COMPUTE sum LABEL “Grand Total: ” OF OWNER_SEG_COUNTS bytes ON report
COMPUTE sum LABEL “Grand Total: ” OF OWNER_SEG_MB bytes ON report

select
cc.file_name,cc.tablespace_name,cc.bytes/1024/1024 “Datafile MB”,cc.status “Datafile Status”,cc.online_status “Online”,aa.file_id,bb.owner,bb.OWNER_SEG_MB,bb.OWNER_SEG_COUNTS
from
(select b.file_id,count(a.segment_name) seg_counts,sum(a.bytes)/1024/1024 seg_sum_mb from dba_segments a,dba_data_files b where a.header_file=b.file_id group by b.file_id) aa,
(select distinct header_file,owner,count(*) owner_seg_counts,sum(bytes)/1024/1024 owner_seg_mb from dba_segments group by header_file,owner order by header_file,owner) bb,
dba_data_files cc
where
aa.file_id(+)=bb.header_file
and aa.file_id=cc.file_id(+)
order by
6,8
;
————————————————————————
Ending。

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

隐藏
变装