Skip to content
pvmehta.com

pvmehta.com

  • Home
  • About Me
  • Toggle search form
  • How to Modify the statistics collection by MMON for AWR repository Oracle
  • Oracle 11g Training on 29JAN1010 Oracle
  • cold backup scripts to copy locally Linux/Unix
  • Wait.sql Oracle
  • This is from Temi Oracle
  • Jai Shree Ram Oracle
  • tblwopk.sql tablewopk.sql Oracle
  • move_arch_files.ksh Linux/Unix
  • All About Trace Fils Oracle
  • New OFA for 11g Oracle
  • V$ROLLSTAT status is Full Oracle
  • Query to Generate aggregate on every 30 mins. Oracle
  • kill all processes from specific user in solaris. Linux/Unix
  • Good RAC & Standby Notes Oracle
  • Some OS level threshold for performance. Linux/Unix

segment_wise_space.sql segspace.sql Segment wise space usage (allocated and used)

Posted on 18-Apr-2006 By Admin No Comments on segment_wise_space.sql segspace.sql Segment wise space usage (allocated and used)

spool seg1

set lines 141

set serveroutput on

execute dbms_output.enable(1000000);

declare

tmp varchar2(1);

v_tbl_name varchar2(100);

v_tot_blocks number;

v_tot_bytes number;

v_unused_blocks number;

v_unused_bytes number;

tot_mb number;

unused_mb number;

v_fileid number;

v_blockid number;

v_block number;

cursor c1 is

select OWNER,

segment_name,

segment_type,

bytes/(1024 *1024) USED_MB,

(extents * initial_extent)/(1024 *1024) Allocated_MB,

Tablespace_name,

extents

from dba_segments

where owner in ( ‘CS’, ‘SCSEDB’, ‘WEBSITEDB’, ‘MCIF’, ‘CIF’ )

and segment_type in (‘TABLE’, ‘INDEX’)

order by owner, tablespace_name, segment_name;

begin

dbms_output.put_line(rpad(‘OWNER’, 15, ‘ ‘) || ‘ ‘ || rpad(‘SEGMENT NAME’, 30, ‘ ‘) || ‘ ‘ ||

rpad(‘TYPE’, 10, ‘ ‘) || ‘ ‘ || rpad(‘ALLOC MB’, 8, ‘ ‘) || ‘ ‘ ||

rpad(‘UNUSD MB’, 8, ‘ ‘) || ‘ ‘ || rpad(‘TS NAME’, 27, ‘ ‘) || ‘ ‘ ||

rpad(‘EXTENTS’, 5, ‘ ‘) || ‘ ‘ || rpad(‘TABLENM’, 30, ‘ ‘) );

dbms_output.put_line(rpad(‘=’, 15, ‘=’) || ‘ ‘ || rpad(‘=’, 30, ‘=’) || ‘ ‘ ||

rpad(‘=’, 10, ‘=’) || ‘ ‘ || rpad(‘=’, 8, ‘=’) || ‘ ‘ ||

rpad(‘=’, 8, ‘=’) || ‘ ‘ || rpad(‘=’, 27, ‘=’) || ‘ ‘ ||

rpad(‘=’, 5, ‘=’) || ‘ ‘ || rpad(‘=’, 30, ‘=’) );

for cur in c1 loop

if cur.segment_type = ‘INDEX’ then

begin

select table_name into v_tbl_name from dba_indexes

where owner = cur.owner

and index_name = cur.segment_name;

exception

when no_data_found then

v_tbl_name := ‘???TBL NOT FOUND???’;

end;

else

v_tbl_name := ‘N/A’;

end if;

dbms_space.unused_space(cur.owner, cur.segment_name, cur.segment_type,

v_tot_blocks, v_tot_bytes, v_unused_blocks, v_unused_bytes,

v_fileid, v_blockid, v_block, null);

tot_mb := v_tot_bytes/(1024 * 1024);

unused_mb := round(v_unused_bytes/(1024 * 1024), 2);

dbms_output.put_line(rpad(cur.owner, 15, ‘ ‘) || ‘ ‘ || rpad(cur.segment_name, 30, ‘ ‘) || ‘ ‘ ||

rpad(cur.segment_type, 10, ‘ ‘) || ‘ ‘ || rpad(tot_mb, 8, ‘ ‘) || ‘ ‘ ||

rpad(unused_mb, 8, ‘ ‘) || ‘ ‘ || rpad(cur.tablespace_name, 27, ‘ ‘) || ‘ ‘ ||

rpad(cur.extents, 5, ‘ ‘) || ‘ ‘ || v_tbl_name );

end loop;

end ;

/

spool off

Oracle, SQL scripts

Post navigation

Previous Post: catall.sh
Next Post: Renaming the column name

Related Posts

  • temp_use.sql diplays usage of temp ts Oracle
  • Handling LOB data in Oracle Oracle
  • Important Script Method for tuning Oracle
  • DBMS_JOB all example Oracle
  • configUOCIOTTO.ora Oracle
  • Multiple listeners Oracle

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Categories

  • AWS (2)
  • Azure (1)
  • Linux/Unix (149)
  • Oracle (388)
  • PHP/MYSQL/Wordpress (10)
  • Power-BI (0)
  • Python/PySpark (7)
  • RAC (17)
  • rman-dataguard (26)
  • shell (149)
  • SQL scripts (337)
  • Uncategorized (0)
  • Videos (0)

Recent Posts

  • findinfo.sql (SQL for getting CPU and Active session info)27-May-2025
  • SQL Tracker by SID sqltrackerbysid.sql22-Apr-2025
  • How to connect to Oracle Database with Wallet with Python.21-Mar-2025
  • JSON/XML Types in Oracle18-Mar-2025
  • CPU Core related projections12-Mar-2025
  • Exadata Basics10-Dec-2024
  • Reading config file from other folder inside class24-Sep-2024
  • Python class import from different folders22-Sep-2024
  • Transfer SQL Profiles from One database to other database.05-Sep-2024
  • Load testing on Oracle 19C RAC with HammerDB18-Jan-2024

Archives

  • 2025
  • 2024
  • 2023
  • 2010
  • 2009
  • 2008
  • 2007
  • 2006
  • 2005
  • Order by with ROWNUM Oracle
  • before_trunc.sql Before Truncate table needs to execute following: Oracle
  • block_ident.sql Oracle
  • Good links for x$ tables in oracle. Oracle
  • Adding Datafile on Primary Server and Impact on Standby Server Oracle
  • Difference between SYNC and AFFIRM Oracle
  • move_arch_files.ksh Linux/Unix
  • find checksum of a file. Linux/Unix

Copyright © 2025 pvmehta.com.

Powered by PressBook News WordPress theme