DECLARE
CURSOR cur_ts IS
SELECT tablespace_name,
SUM(bytes) bytes
FROM dba_data_files
GROUP BY tablespace_name;
CURSOR cur_ts_fs(p_ts VARCHAR2) IS
SELECT SUM(BYTES) fs,
MAX(bytes) mx
FROM dba_free_space
WHERE tablespace_name = p_ts;
lv_fs NUMBER := 0;
percent_fs NUMBER := 0;
large_fs NUMBER := 0;
lv_name V$database.name%TYPE;
BEGIN
DBMS_OUTPUT.enable(1000000);
SELECT name into lv_name from v$database;
DBMS_OUTPUT.PUT_LINE('*****************'||lv_name||' Database -- Tablespace Summary - Freespace Report *********************');
DBMS_OUTPUT.PUT_LINE('Tablespace name ' ||
' Total Space(B)' ||
' Used Space(B) ' ||
'Largest Free Space(B)' ||
' %Free Space');
DBMS_OUTPUT.PUT_LINE('**************** ' ||
' **************' ||
' ************* ' ||
'*********************' ||
' ***********');
FOR lv_cur_ts IN cur_ts LOOP
FOR lv_cur_ts_fs IN cur_ts_fs(lv_cur_ts.tablespace_name) LOOP
lv_fs := lv_cur_ts.bytes - lv_cur_ts_fs.fs;
percent_fs := ( (lv_cur_ts_fs.fs) /(lv_cur_ts.bytes) ) * 100;
large_fs := lv_cur_ts_fs.mx;
END LOOP;
DBMS_OUTPUT.PUT_LINE(RPAD(lv_cur_ts.tablespace_name,20)||
LPAD(lv_cur_ts.bytes,20)||
LPAD(lv_fs,20)||
LPAD(large_fs,20)||
LPAD( ROUND(percent_fs,2),12)
);
END LOOP;
END;
Welcome to the GEEK world, best place where you find topic about latest cutting edge technology on website and mobile. Learn and grow your knowledge with the information and tutorials about Website designing, CSS tutorials, Java Script tutorials, Ruby tutorials, ROR tutorials, HTML tutorials, HTML5 , JQuery, Javascript tutorials, Photoshop tutorials, Flash, games tutorials, Cheat sheets, Design tools, Action Scripts as well as MySql, Oracle and many more in a easy way to use and understand.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment