zoukankan      html  css  js  c++  java
  • oracle查看表实际物理空间使用大小

    http://www.2cto.com/database/201107/95313.html

    一种是分配给一个表的物理空间数量,而不管空间是否被使用。可以这样查询获得字节数:
    select segment_name, bytes 
    from user_segments 
    where segment_type = 'TABLE';

     或

    Select Segment_Name,Sum(bytes)/1024/1024 from User_Extents Group By Segment_Name;

    另一种实际使用的空间

    analyze table emp compute statistics; 
    select num_rows * avg_row_len/1024/1024 "实际大小(M)"
    from user_tables 
    where table_name = 'EMP';--EMP为表名(表名大写查询) 

    附:
    查看每个表空间的大小
    Select Tablespace_Name,Sum(bytes)/1024/1024 from Dba_Segments Group By Tablespace_Name 
    1.查看剩余表空间大小
     
    SELECT tablespace_name 表空间,sum(blocks*8192/1000000) 剩余空间M from dba_free_space GROUP BY tablespace_name;
     
    2.检查系统中所有表空间总体空间
    select b.name,sum(a.bytes/1000000)总空间 from v$datafile a,v$tablespace b where a.ts#=b.ts# group by b.name;
     
    3.查询整个数据库剩余和使用的表空间大小使用情况:
    select df.tablespace_name "表空间名",totalspace "总空间M",freespace "剩余空间M",round((1-freespace/totalspace)*100,2) "使用率%" 
    from 
    (select tablespace_name,round(sum(bytes)/1024/1024) totalspace 
    from dba_data_files 
    group by tablespace_name) df, 
    (select tablespace_name,round(sum(bytes)/1024/1024) freespace 
    from dba_free_space 
    group by tablespace_name) fs 
    where df.tablespace_name=fs.tablespace_name;
    效果如下:
     

  • 相关阅读:
    1822. Sign of the Product of an Array
    1828. Queries on Number of Points Inside a Circle
    1480. Running Sum of 1d Array
    C++字符串
    Git&GitHb学习记录
    54. Spiral Matrix
    104. Maximum Depth of Binary Tree
    110. Balanced Binary Tree
    136. Single Number
    19、泛型入门
  • 原文地址:https://www.cnblogs.com/peterpanzsy/p/3488855.html
Copyright © 2011-2022 走看看