Skip to content
pvmehta.com

pvmehta.com

  • Home
  • About Me
  • Toggle search form
  • Rename Oracle Instance Name Oracle
  • create trigger syntax Oracle
  • Space padding in korn shell Linux/Unix
  • Search and replace pattern Linux/Unix
  • good note for shared pool tunnig Oracle
  • Good Oracle Architecture In Short and point to point Oracle
  • longtx.sql with the flag whether session is blocking any DML locks or not. Oracle
  • SCRIPT TO LIST RECURSIVE DEPENDENCY BETWEEN OBJECTS UTLDTREE.sql Oracle
  • compile_inv.sql Oracle
  • switchlogfile.sh Linux/Unix
  • CPU speed on Linux Linux/Unix
  • Reading parameter file and printing Linux/Unix
  • How to calculate PROCESSES parameter Oracle
  • For Perl DBI installation and testing program PHP/MYSQL/Wordpress
  • catting.sh 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

  • How To Resolve Stranded DBA_2PC_PENDING Entries ID 401302.1 (Very Good prooven) Oracle
  • get_aix_vmstat.ksh Oracle
  • Set Role explaination. Oracle
  • RAC with RHEL4 and 11g Oracle
  • find_pk.sql /* Find Primary Key */ Oracle
  • How to set Processes Parameter Oracle

Leave a Reply Cancel reply

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

Categories

  • Ansible (0)
  • AWS (2)
  • Azure (1)
  • Linux/Unix (149)
  • MYSQL (5)
  • Oracle (392)
  • PHP/MYSQL/Wordpress (10)
  • POSTGRESQL (0)
  • Power-BI (0)
  • Python/PySpark (7)
  • RAC (17)
  • rman-dataguard (26)
  • shell (149)
  • SQL scripts (341)
  • SQL Server (6)
  • Uncategorized (0)
  • Videos (0)

Recent Posts

  • SQL Server Vs Oracle Architecture difference25-Jul-2025
  • SQL Server: How to see historical transactions25-Jul-2025
  • SQL Server: How to see current transactions or requests25-Jul-2025
  • T-SQL Vs PL/SQL Syntax25-Jul-2025
  • Check SQL Server edition25-Jul-2025
  • Checking SQL Server Version25-Jul-2025
  • Oracle vs MYSQL Architecture differences (For DBAs)24-Jul-2025
  • V$INSTANCE of Oracle in MYSQL24-Jul-2025
  • Day to day MYSQL DBA operations (Compared with Oracle DBA)24-Jul-2025
  • MYSQL and Oracle Comparison for Oracle DBA24-Jul-2025

Archives

  • 2025
  • 2024
  • 2023
  • 2010
  • 2009
  • 2008
  • 2007
  • 2006
  • 2005
  • pvm_metric.sql for gathering report from vmstat tables Oracle
  • get_vmstat.ksh Linux/Unix
  • age_alert.ksh aging out alert.log Linux/Unix
  • checking connectivity between two servers Linux/Unix
  • 10g oem configuration Oracle
  • cp_filesystem.sql Oracle
  • Rownum with Order by Oracle
  • restarting network in linux Linux/Unix

Copyright © 2025 pvmehta.com.

Powered by PressBook News WordPress theme