我想查看一个表有多大,
于是我先分析下该表,analyze table table_name compute statistics;
然后select * from user_table where table_name = '';
然后发现有个字段是 sample_size,请问这个是表大小吗?如果是它的单位是什么,怎么看?如果是不那表大小怎么看呢?
于是我先分析下该表,analyze table table_name compute statistics;
然后select * from user_table where table_name = '';
然后发现有个字段是 sample_size,请问这个是表大小吗?如果是它的单位是什么,怎么看?如果是不那表大小怎么看呢?
如果是表空间的话应该是这个吧
select segment_name,tablespace_name,bytes,blocks from user_segments
在 sqlpluse 中执行:
analyze table table_name compute statistics;
或者执行 oracle 系统包:
exec DBMS_STATS.GATHER_TABLE_STATS(.....);
然后查询user_tables ,里面有初始空间,空闲空间,已用空间等等参数.
dba_data_files -- 用于统计已经使用的表数据文件的大小
dba_free_space -- 用于统计还未使用的表数据文件的大小语句如下:
SELECT a.tablespace_name,a.bytes/1024/1024 "sum MB",
(a.bytes-b.bytes)/1024/1024 "used MB",
b.bytes/1024/1024 "free MB",
ROUND(((a.bytes-b.bytes)/a.bytes)*100,2) "percent_used"
FROM
(SELECT tablespace_name, SUM(bytes) bytes
FROM dba_data_files
GROUP BY tablespace_name) a,
(SELECT tablespace_name, SUM(bytes) bytes, MAX(bytes) largest
FROM dba_free_space
GROUP BY tablespace_name) b
WHERE a.tablespace_name = b.tablespace_name
AND a.tablespace_name = '你想查的表的表空间名字'
ORDER BY ((a.bytes-b.bytes)/a.bytes) DESC
exec dbms_stats.gather_table_stats('SCOTT', 'TEST_YIXL');
2.查看User_tables内容信息
select * from user_tables where table_name = 'TEST_YIXL';
字段【BLOCKS】就是表已使用的块数,转换成字节(bytes)数:BLOCKS*8*1024(每个块占8k大小);
字段【SAMPLE_SIZE】是分析表时使用的空间大小,单位应该也是块数。
那么也就是 字段blocks 与字段sample_size 能够反映表的大小了?【SAMPLE_SIZE】的单位也是块了?
SELECT table_name,
NUM_ROWS,
BLOCKS*8/1024/1024 "Size M",
EMPTY_BLOCKS,
LAST_ANALYZED
from user_tables
where table_name='EMP';
dba_extents 有segment分配的extents的大小
dba_table 有该table的大小
不清楚表字段的意思查下联机手册就是了
g_member';BLOCKS*8.192/1024
-----------------
4.016SQL> select sum(bytes)/1024/1024/*,segment_name*/ from user_segments where lowe
r(segment_name) = 'v3x_org_member';SUM(BYTES)/1024/1024/*,SEGMENT_NAME*/
-------------------------------------
4结果是一样的,不过是不同形式体现而已,条条大路通罗马。