nieyuqin

sqlplus查询oracle数据库数据容量

登录sqlplus:

cmd命令行登录:sqlplus orcl/orcl as sysdba

查询表空间使用率

select b.file_id  文件ID,

  b.tablespace_name  表空间,

  b.file_name     物理文件名,

  b.bytes       总字节数,

  (b.bytes-sum(nvl(a.bytes,0)))   已使用,

  sum(nvl(a.bytes,0))        剩余,

  sum(nvl(a.bytes,0))/(b.bytes)*100 剩余百分比

  from dba_free_space a,dba_data_files b

  where a.file_id=b.file_id

  group by b.tablespace_name,b.file_name,b.file_id,b.bytes

  order by b.tablespace_name

 

select tablespace_name, segment_name, bytes / 1024 / 1024    from user_segments  where segment_type = \'TABLE\'    and tablespace_name = \'VNOX\'  order by bytes desc ;

 

查询表空间总大小(DBA_DATA_FILES和DBA_SEGMENTS,DBA_FREE_SPACE区别)

1, dba_data_files,dba_segments,dba_free_space
得出结论:一般情况下(没有drop表的时候):dba_data_files bytes = (dba_segments bytes + dba_free_space bytes)

实验:

SQL> Select sum(bytes)/1024/1024/1024 from dba_segments;
SUM(BYTES)/1024/1024/1024
-------------------------
           1.58441162

SQL> select sum(bytes)/1024/1024/1024 from dba_free_space;
SUM(BYTES)/1024/1024/1024
-------------------------
           .323669434

SQL> select sum(bytes)/1024/1024/1024 from dba_data_files;
SUM(BYTES)/1024/1024/1024
-------------------------
        1.9140625

分类:

技术点:

相关文章:

  • 2021-11-04
  • 2021-04-19
  • 2022-01-24
  • 2021-04-24
  • 2021-06-04
  • 2022-12-23
  • 2021-07-12
  • 2021-12-09
猜你喜欢
  • 2021-11-17
  • 2021-11-02
  • 2022-12-23
  • 2022-12-23
  • 2021-12-03
  • 2022-12-23
  • 2021-12-22
相关资源
相似解决方案