度量快速开发平台-专业、快速的软件定制快开平台

标题: 利用dba_segments视图查询oracle数据库对象的空间占用情况 [打印本页]

作者: 万望    时间: 2020-5-11 21:41
标题: 利用dba_segments视图查询oracle数据库对象的空间占用情况
假设需要查询oracle数据库中某个表的空间占用情况,那么,可以利用dba_segments这个视图。比如,如下图1所示,查询的就是cmx_arif_history这张表的空间占用大小,之所以用sum函数进行累加,是因为该表占用了好几个分区,所以查询出来有很多记录,需要通过sum函数进行求和累加。


dba_segments视图有很多字段,各自代表的意思如下所示(可以通过查看该表的comments得到):




字段名
字段说明
OWNER
Username of the segment owner
SEGMENT_NAME
Name, if any, of the segment
PARTITION_NAME
Partition/Subpartition Name, if any, of the segment
SEGMENT_TYPE
Type of segment:  "TABLE", "CLUSTER", "INDEX", "ROLLBACK", "DEFERRED ROLLBACK", "TEMPORARY","SPACE HEADER", "TYPE2 UNDO" or "CACHE"
SEGMENT_SUBTYPE
SubType of Lob segment:  "SECUREFILE", "ASSM", "MSSM", NULL
TABLESPACE_NAME
Name of the tablespace containing the segment
HEADER_FILE
ID of the file containing the segment header
HEADER_BLOCK
ID of the block containing the segment header
BYTES
Size, in bytes, of the segment
BLOCKS
Size, in Oracle blocks, of the segment
EXTENTS
Number of extents allocated to the segment
INITIAL_EXTENT
Size, in bytes, of the initial extent of the segment
NEXT_EXTENT
Size, in bytes, of the next extent to be allocated to the segment
MIN_EXTENTS
Minimum number of extents allowed in the segment
MAX_EXTENTS
Maximum number of extents allowed in the segment
MAX_SIZE
Maximum number of blocks allowed in the segment
RETENTION
Retention option for SECUREFILE segment
MINRETENTION
Minimum Retention Duration for SECUREFILE segment
PCT_INCREASE
Percent by which to increase the size of the next extent to be allocated
FREELISTS
Number of process freelists allocated in this segment
FREELIST_GROUPS
Number of freelist groups allocated in this segment
RELATIVE_FNO
Relative number of the file containing the segment header
BUFFER_POOL
The default buffer pool to be used for segments blocks


对于上面的表格,补充以下说明:

header_file:表示这个段的头在哪个数据文件里面,因为段可以跨数据文件。

header_block:表示这个段的头在数据文件的第几个block里面。

bytes:段的空间大小,至于是当前占用的空间大小还是分配给它的空间大小,这个很好测试,批量查一些数据进去,先后对比下就知道了。

blocks:段占用了多少个block。

extends:分配了多少个extend。

initial_extend:初始分配的extend大小(以byte计)。

next_extend:下一个分配的extend大小(以byte计)。如果为空,则表示是自动分配。每个extend可以有不同大小,如果设置为uniform的话,每个extend就一样大小了。

min_extend:最少分配多少个extend(以个数计)。

max_extend:最多分配多少个extend(以个数计)。

pct_increase:percent increase表示第三个或后续的extent的大小比前一个增加的百分比,如第一个extent是64K,第二个是64K,pct_increase=50%,则第三个extent是64K*1.5=96K,第四个96K*1.5=144K,依次类推。

relative_fno:该段所在数据文件的relative fno。

freelists和freelist_groups:该字段在字典管理的表空间中才有意义。



作者: 陈晓龙    时间: 2020-5-12 16:42

作者: 陈晓龙    时间: 2020-5-12 16:43

作者: 陈晓龙    时间: 2020-5-12 16:43

作者: 陈晓龙    时间: 2020-5-15 13:58
好东西
作者: 陈晓龙    时间: 2020-5-15 13:58
不错




欢迎光临 度量快速开发平台-专业、快速的软件定制快开平台 (http://bbs.delit.cn/) Powered by Discuz! X3.2