我想查看一个表有多大,
于是我先分析下该表,analyze table table_name compute statistics;
然后select * from user_table where table_name = '';
然后发现有个字段是 sample_size,请问这个是表大小吗?如果是它的单位是什么,怎么看?如果是不那表大小怎么看呢?

解决方案 »

  1.   

    你想问的是表空间大小吗?
    如果是表空间的话应该是这个吧
    select segment_name,tablespace_name,bytes,blocks from user_segments
      

  2.   

    学习一下。oracle的体系结构吧。
      

  3.   

    数据字典 user_tables 数字字典中包含了你所需要的信息,比如表中存储的记录数 NUM_OWS,所占用的数据块数BLOCKS等。 但需要对你要关注的那张表进行统计分析user_tables 数据字典中的这些数据才是准确的, 对表进行分析的方法:
    在 sqlpluse 中执行:
    analyze table table_name compute statistics; 
    或者执行 oracle 系统包:
    exec DBMS_STATS.GATHER_TABLE_STATS(.....); 
    然后查询user_tables ,里面有初始空间,空闲空间,已用空间等等参数.
      

  4.   

    查表大小,其实就是已经使用的表空间的大小,主要用到两张表:dba_data_files, dba_free_space
    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
      

  5.   

    1.首先搜集表的统计信息,以表TEST_YIXL为例
    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】是分析表时使用的空间大小,单位应该也是块数。
      

  6.   

    查对应的segment大小.一般的表一般对应一个同名的segment.分区表,簇例外.
      

  7.   


    那么也就是 字段blocks 与字段sample_size 能够反映表的大小了?【SAMPLE_SIZE】的单位也是块了?
      

  8.   


    SELECT table_name, 
    NUM_ROWS, 
    BLOCKS*8/1024/1024 "Size M", 
    EMPTY_BLOCKS, 
    LAST_ANALYZED 
    from user_tables 
    where table_name='EMP'; 
      

  9.   

    不想记sql的话 可以装个toad,直接从toad里查就可以了
      

  10.   

    dba_segments 有segment的大小
    dba_extents  有segment分配的extents的大小
    dba_table    有该table的大小
    不清楚表字段的意思查下联机手册就是了
      

  11.   

    表的大小查询是这样的 : select sum(bytes)/1024/1024||'M' size from user_segments t where t.segment_name= 'table_name'这样查询出的是表的大小单位是 M
      

  12.   

    SQL> select blocks*8.192/1024 from user_tables where lower(table_name) = 'v3x_or
    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结果是一样的,不过是不同形式体现而已,条条大路通罗马。