oracle如何查看表空间大小及使用情况

avatar
作者
筋斗云
阅读量:0

可以使用以下SQL语句来查看表空间的大小及使用情况:

  1. 查看表空间的总大小、已使用空间和剩余空间:
SELECT tablespace_name,        ROUND(SUM(bytes) / 1024 / 1024, 2) AS total_space_mb,        ROUND(SUM(bytes - decode(maxbytes, 0, bytes, maxbytes)) / 1024 / 1024, 2) AS used_space_mb,        ROUND(SUM(decode(maxbytes, 0, bytes, maxbytes) - bytes) / 1024 / 1024, 2) AS free_space_mb   FROM dba_data_files  GROUP BY tablespace_name; 
  1. 查看每个数据文件的使用情况:
SELECT file_name,        tablespace_name,        ROUND(bytes / 1024 / 1024, 2) AS file_size_mb,        ROUND(bytes - decode(maxbytes, 0, bytes, maxbytes) / 1024 / 1024, 2) AS used_space_mb,        decode(maxbytes, 0, bytes, maxbytes) / 1024 / 1024 AS max_space_mb,        autoextensible,        status   FROM dba_data_files; 
  1. 查看每个表空间的数据文件及其使用情况:
SELECT tablespace_name,        file_name,        ROUND(bytes / 1024 / 1024, 2) AS file_size_mb,        ROUND(maxbytes / 1024 / 1024, 2) AS max_size_mb,        ROUND(bytes - decode(maxbytes, 0, bytes, maxbytes) / 1024 / 1024, 2) AS used_space_mb,        decode(maxbytes, 0, bytes, maxbytes) / 1024 / 1024 AS max_space_mb,        autoextensible,        status   FROM dba_data_files; 

广告一刻

为您即时展示最新活动产品广告消息,让您随时掌握产品活动新动态!