Skip to content
pvmehta.com

pvmehta.com

  • Home
  • About Me
  • Toggle search form
  • Check_recovery.sh program to run sqlplus and return its values remotely. Linux/Unix
  • normal maintenance for exp-imp and renaming table Oracle
  • Load SPM baseline from AWR Oracle
  • Nice Article about semaphores and init.ora Processes parameter relations Linux/Unix
  • Virtual Indexes in Oracle Oracle
  • get_vmstat.ksh Linux/Unix
  • How to see which patches are applied. Oracle
  • get_vmstat_solaris Oracle
  • How does one SELECT a value from a table into a Unix variable? From SQL to Shell Linux/Unix
  • sess_server.sql Oracle
  • Oracle GoldenGate lag monitoring shell script Linux/Unix
  • move_arch_files.ksh Linux/Unix
  • reset Sequence Oracle
  • move_arch_files.ksh Linux/Unix
  • Oracle 11g Environment Setup 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

  • 276434.1 Modifying the VIP or VIP Hostname of a 10g or 11g Oracle Clusterware Node Oracle
  • Does DBMS_JOB recompute the NEXT_DATE interval after or before Oracle
  • Rman Notes -1 Oracle
  • Good notes on Oracle Events Oracle
  • OEM-troubleshooting on 20-MAY-08 Oracle
  • shr1.sql for MTS or Shared server configuration 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
  • how to find VIP from ifconfig Linux/Unix
  • database trigger failing Oracle
  • 556976.1 Oracle Clusterware: Components installed Oracle
  • RAC 11g with vmware Oracle
  • DBMS_JOB all example Oracle
  • Removing first line Linux/Unix
  • Looping for remote servers and find its database from oratab file. Linux/Unix
  • Export Import with QUERY Oracle

Copyright © 2025 pvmehta.com.

Powered by PressBook News WordPress theme