温馨提示×

oracle数据库表空间使用率查询

小樊
89
2024-07-16 02:03:43
栏目: 云计算
亿速云空间服务器,独享5M带宽,BGP线路,安全稳定,不到0.96元/天! 查看详情>>

To check the tablespace usage in an Oracle database, you can query the DBA_TABLESPACES view. Here is an example SQL query that will show the usage of each tablespace in the database:

SELECT tablespace_name,
       ROUND((1 - (free_space / total_space)) * 100, 2) AS used_percent
FROM
  (SELECT tablespace_name,
          SUM(bytes) / 1024 / 1024 AS total_space,
          SUM(maxbytes) / 1024 / 1024 AS max_space,
          SUM(bytes - decode(autoextensible, 'YES', maxbytes, bytes)) / 1024 / 1024 AS free_space
   FROM dba_data_files
   GROUP BY tablespace_name);

This query will return the name of each tablespace in the database along with the percentage of space that is currently being used. The used_percent column will show how much of each tablespace is currently in use.

亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

推荐阅读:如何查看数据库表空间使用率

0