Skip to content
pvmehta.com

pvmehta.com

  • Home
  • About Me
  • Toggle search form
  • executing Function from SQLPLUS prompt Oracle
  • Debugging Shell FIles Linux/Unix
  • proc.sql Oracle
  • Oracle 11g Environment Setup Oracle
  • PLSQL Table Syntax 2 Oracle
  • Gather Stats manually using DBMS_STATS after disabling DBMS_SCHEDULER jobs as previous entry Oracle
  • SYSOPER Mystery Oracle
  • moving lob object to other tablespace lob_mvmt.sql Oracle
  • exp syntax in oracle 10g Oracle
  • Find Time Consuming SQL Statements in Oracle 10g Oracle
  • restarting network in linux Linux/Unix
  • Follwoing korn shell is used to move files from source folder to destination folder and gzip it in destination folder. mv_iotto.ksh Linux/Unix
  • longtx.sql Oracle
  • DBA_HIST_SQLSTAT contents Oracle
  • Goldengate document from Porus Oracle

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

  • longtx.sql Oracle
  • Find Stale DR Physical Standby Oracle
  • TOP-N Sql to find Nth max or Top N rows Oracle
  • create trigger syntax Oracle
  • Library cahe Latches and internal explaination Oracle
  • Drop database in Oracle 10g 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 (392)
  • PHP/MYSQL/Wordpress (10)
  • Power-BI (0)
  • Python/PySpark (7)
  • RAC (17)
  • rman-dataguard (26)
  • shell (149)
  • SQL scripts (341)
  • Uncategorized (0)
  • Videos (0)

Recent Posts

  • load SPM baseline from cursor cache05-Jun-2025
  • Drop all SPM baselines for SQL handle05-Jun-2025
  • Load SPM baseline from AWR05-Jun-2025
  • Drop specific SQL plan baseline – spm05-Jun-2025
  • 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

Archives

  • 2025
  • 2024
  • 2023
  • 2010
  • 2009
  • 2008
  • 2007
  • 2006
  • 2005
  • Good link for LIO in Oracle ( Logical IOs) Oracle
  • Changing default shell Linux/Unix
  • Jai Shree Ram Oracle
  • How to Modify the statistics collection by MMON for AWR repository Oracle
  • handling filenname with space Linux/Unix
  • Implementing Listener Security Oracle
  • AWR license Oracle
  • Identical Dblink Issue… Oracle

Copyright © 2025 pvmehta.com.

Powered by PressBook News WordPress theme