1
SELECT tablespace_name, sum(bytes)/1024/1024 "MB Free"
  FROM dba_free_space 
 WHERE tablespace_name = 'USERS'
 GROUP BY tablespace_name;

大家好,上面的查询是我用来显示用户表空间中的可用空间的,但是我如何编写一个单独的PL/SQL脚本来将它存储在带有表空间名称和时间戳的单独表中。

请帮助我,因为我需要每小时在作业调度程序上运行一次。

提前致谢

4

1 回答 1

2

Assuming you've already created the table you want to store the data in, simply

CREATE OR REPLACE PROCEDURE snap_free_space
AS
BEGIN
  INSERT INTO new_table( tablespace_name, free_bytes, collection_time )
    SELECT tablespace_name, sum(bytes), sysdate
      FROM dba_free_space
     GROUP BY tablespace_name;
END;
于 2011-10-07T21:47:50.913 回答