oracle

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

小樊
86
2024-07-16 02:03:43
栏目: 云计算

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.

0
看了该问题的人还看了