create table db_space_hist ( timestamp date, total_space number(8), used_space number(8), free_space number(8), pct_inuse number(5,2), num_db_files number(5) ) tablespace users; create or replace procedure db_space_hist_proc as begin -- Delete old records... delete from db_space_hist where timestamp > SYSDATE + 364; -- Insert current utilization values... insert into db_space_hist select sysdate, total_space, total_space-nvl(free_space,0) used_space, nvl(free_space,0) free_space, ((total_space - nvl(free_space,0)) / total_space)*100 pct_inuse, num_db_files from ( select sum(bytes)/1024/1024 free_space from sys.DBA_FREE_SPACE ) FREE, ( select sum(bytes)/1024/1024 total_space, count(*) num_db_files from sys.DBA_DATA_FILES) FULL; commit; end; / show errors begin dbms_scheduler.create_job( job_name => 'tablespace_history', job_type => 'PLSQL_BLOCK', job_action => 'begin db_space_hist_proc; end;', start_date => SYSTIMESTAMP, repeat_interval => 'freq=weekly; byday=sun', end_date => null, enabled => TRUE, comments => 'Job storing the statistics about database space to db_space_hist table '); end; Running the job: BEGIN DBMS_SCHEDULER.run_job (job_name => 'tablespace_history'); END;