zoukankan      html  css  js  c++  java
  • 查询oracle数据库表空间的大小,已使用空间,剩余空间

    1. 查看所有表空间大小
    SQL> select tablespace_name,sum(bytes)/1024/1024 from dba_data_files (数据文件)
            2  group by tablespace_name;

    2. 已经空闲的表空间大小
    SQL> select tablespace_name,sum(bytes)/1024/1024 from dba_free_space(空闲表空间)
        2  group by tablespace_name;

    3. 所以使用空间可以这样计算
      select a.tablespace_name,total,free,total-free used from 
     (select tablespace_name,sum(bytes)/1024/1024 total from dba_data_files
         group by tablespace_name) a, 
      ( select tablespace_name,sum(bytes)/1024/1024 free from dba_free_space
         group by tablespace_name) b
      where a.tablespace_name=b.tablespace_name;

    4. 下面这条语句查看所有segment的大小。
    Select Segment_Name,Sum(bytes)/1024/1024 From User_Extents Group By Segment_Name

    5. 还有在命令行情况下如何将结果放到一个文件里。
    SQL> spool out.txt
    SQL> select * from v$database;
    SQL> spool off

  • 相关阅读:
    2017-12-25
    oracle 创建表,增加修改删除字段
    jqxWidgets 常用代码
    Oracle初始化用户-表空间-权限
    Oracle 切换数据库实例
    ORE(Oracle R Enterprise)安装步骤
    Java 枚举类的基本使用
    Java可变参数
    java的封箱和拆箱
    spring 九种设计模式
  • 原文地址:https://www.cnblogs.com/hzhida/p/2636886.html
Copyright © 2011-2022 走看看