阅读量:0
可以使用以下SQL语句来查看表空间的大小及使用情况:
- 查看表空间的总大小、已使用空间和剩余空间:
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;
- 查看每个数据文件的使用情况:
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;
- 查看每个表空间的数据文件及其使用情况:
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;