溫馨提示×

oracle如何查看表空間大小及使用情況

小億
396
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
亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女