Quick Search:
CODE
Oracle PL/SQL Code Library
JOBS
Find Or Post Oracle Jobs
FORUM
Oracle Discussion & Chat
 Oracle PL/SQL: DBA Free Space Jump to:  
Category: >> Oracle PL/SQL >> DBA Free Space Bookmark and Share

<< lastnext >>

Snippet Name: DBA Free Space

Description: Returns details of available space in particular tablespaces.

Also see:
» Add PSOUG Search to SQL Developer
» Converting Rows to Columns
» Database Links: CURRENT_USER
» Instant Test Database with DCBA
» Show info on current context
» Lookup Oracle error messages
» Display and release DBMS_LOCK locks
» Display locks and latches
» Show rollback segment stats
» Show active transactions
» List supported INIT.ORA parameters
» Display database SGA statistics
» Measure the Buffer Cache Hit Ratio
» List security related profile informat...
» Find users with deadly privileges
» Audit User Logins (User Login Trigger)
» Block TOAD and other tools
» Kill Session
» Extents
» DBA Users
» DBA Tablespaces
» DBA triggers
» DBA Sessions
» DBA Roles
» DBA Objects
» DBA Links
» DBA Jobs
» Job Queue
» Data Files
» DBA Extents

Comment: (none)

Language:
Highlight Mode: PLSQL
Last Modified: February 28th, 2009

CREATE TABLE tl_contig_space (
tablespacE_name CHAR(30),
file_id NUMBER,
block_id NUMBER,
starting_file_id NUMBER,
starting_block_id NUMBER,
blocks NUMBER,
bytes NUMBER)
tablespace system
storage (initial 64K next 64K pctincrease 0);
 
 
 
CREATE VIEW vw_new_look AS
SELECT tablespace_name,
starting_file_id,
starting_block_id,
SUM(blocks) sum_blocks,
COUNT(blocks) count_blocks,
MAX(blocks) max_blocks,
SUM(bytes) sum_bytes
FROM tl_contig_space
GROUP BY tablespace_name, starting_file_id, starting_block_id
/
 
 
 
DECLARE
   CURSOR query IS
   SELECT *
   FROM dba_free_space
   ORDER BY tablespace_name, file_id, block_id;
this_row   query%ROWTYPE;
previous_row   query%ROWTYPE;
old_file_id    INTEGER;
old_block_id   INTEGER;
BEGIN
   OPEN query;
   FETCH query INTO this_row;
   previous_row := this_row;
   old_file_id := previous_row.file_id;
   old_block_id := previous_row.block_id;
   WHILE query%FOUND LOOP
      IF this_row.file_id = previous_row.file_id
      AND this_row.block_id = previous_row.block_id + previous_row.blocks THEN
         INSERT INTO tl_contig_space
         (tablespace_name,
          file_id,
          block_id,
          starting_file_id,
          starting_block_id,
          blocks,
          bytes)
          VALUES
          (previous_row.tablespace_name,
          previous_row.file_id,
          this_row.block_id,
          old_file_id,
          old_block_id,
          this_row.blocks,
          this_row.bytes);
          COMMIT;
      ELSE
         INSERT INTO tl_contig_space
         (tablespace_name,
          file_id,
          block_id,
          starting_file_id,
          starting_block_id,
          blocks,
          bytes)
          VALUES
          (this_row.tablespace_name,
          this_row.file_id,
          this_row.block_id,
          this_row.file_id,
          this_row.block_id,
          this_row.blocks,
          this_row.bytes);
          old_file_id := this_row.file_id;
          old_block_id := this_row.block_id;
          COMMIT;
      END IF;
      previous_row := this_row;
      FETCH query INTO this_row;
   END LOOP;
END;
/
 


Free
Oracle Magazine
Subscriptions
and Oracle White Papers


SQL University.net courses meet the most demanding needs of the business world for advanced education in a cost-effective manner. SQL University.net courses are available immediately for IT professionals and can be taken without disruption of your workplace schedule or processes.

Compared to traditional travel-based training, SQL University.net saves time and valuable corporate resources, allowing companies to do more with less. That's our mission, and that's what we deliver.

Click here to find out more
 
Home      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us 277 users online    © 2009 psoug.org

PSOUG LOGIN
Username: 
Password: 
Forgot your password?