oracle

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

小亿
297
2024-03-21 16:14:55
栏目: 云计算

可以使用以下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;

0
看了该问题的人还看了