문제

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

Hi everyone, the above query is what i use for showing the free space in user tablespace but how do i write a separate PL/SQL script to store it in separate table with tablespace name and time stamp.

Kindly help me as i need this run on job scheduler for every hour.

Thanks in advance

도움이 되었습니까?

해결책

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;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top