Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> Oracle 9i, a better way to use dbms_space
Hi all,
I was working on making dbms_space.space_usage for all my LMT tablespaces. The procedure is perfect, but I didn't want to wait too long till the pl/sql block finishes it work and dbms_output.put_line works its magic. So here is my take on the code ... if you want, feel free to use it.
It should work in 9i onwards, but I have tested this only on 9202. Sorry, this logic won't work for pre-9i versions.
An example is as follows ...
5 ,total_blocks 6 ,full_blocks 7 ,(fs1_blocks+fs2_blocks+fs3_blocks+fs4_blocks) partial_blocks 8 ,unformatted_blocks
SQL> SQL> set timing on SQL> @test_space NM TOTAL_BLOCKS FULL_BLOCKS PARTIAL_BLOCKSUNFORMATTED_BLOCKS
INTRSCH_ACTUAL_UNIVS 60 4 44 12 INTRSCH_BASE_DEMOS 60 0 16 44 INTRSCH_CMP_ACTIMPS 1 0 0 0 INTRSCH_CMP_EPRTGS 1 0 0 0 INTRSCH_DAYPARTS 60 0 16 44 INTRSCH_DAYPART_DAYS 60 1 15 44 INTRSCH_DEMO_FORMULAS 60 0 16 44 INTRSCH_ESP_ACTIMPS 23752 23623 129 0 INTRSCH_ESP_EPRTGS 2832 2805 27 0 INTRSCH_MONTH_SUMMARY 1 0 0 0 INTRSCH_QH_CMP_IMPS 1 0 0 0 INTRSCH_QH_ESP_IMPS 1 0 0 0 INTRSCH_SAVED_EPS 124 2 122 0 TMP_INTRSCH_DATA 1 0 0 0 TMP_INTRSCH_DATES 124 0 64 60 TMP_INTRSCH_EPRT 60 0 124 0 TMP_INTRSCH_EPRT_SUMMARY 1 0 80 44 TMP_INTRSCH_EXCL_SPORT 1 0 0 0 TMP_INTRSCH_INCL_SPORT 124 0 48 76 TMP_INTRSCH_TIMES 124 0 6460
20 rows selected.
Elapsed: 00:00:00.02
The code is as follows ...
/
GRANT ALL ON SPACE$free_blocks_tbl TO sys
/
GRANT ALL ON SPACE$free_blocks TO sys
/
CREATE OR REPLACE FUNCTION Get_Free_Blocks
(p_own IN VARCHAR2, p_tab IN VARCHAR2)
RETURN SPACE$free_blocks_tbl pipelined AS
--
CURSOR cur_main (c_own VARCHAR2, c_tbl VARCHAR2) IS
SELECT owner, table_name, blocks
FROM DBA_TABLES WHERE owner LIKE UPPER(c_own) || '%' AND table_name LIKE UPPER(c_tbl) || '%' ORDER BY owner, table_name; -- nUnBlocks NUMBER; nUnBytes NUMBER; nFS1Blocks NUMBER; nFS1Bytes NUMBER; nFS2Blocks NUMBER; nFS2Bytes NUMBER; nFS3Blocks NUMBER; nFS3Bytes NUMBER; nFS4Blocks NUMBER; nFS4Bytes NUMBER; nFullBlocks NUMBER; nFullBytes NUMBER;
If you use it, your feedback or suggestions to enhance it are greatly appreciated. I am working on extending this to accomodate indexes as well, just don't have time that's all.
Raj
--
Please see the official ORACLE-L FAQ: http://www.orafaq.net
--
Author: Jamadagni, Rajendra
INET: Rajendra.Jamadagni_at_espn.com
Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting servicesto: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
![]() |
![]() |