Skip to content
pvmehta.com

pvmehta.com

  • Home
  • About Me
  • Toggle search form
  • Database logon trigger issue Oracle
  • Find Command Linux/Unix
  • Adding a new disk and mount it automatically. on VMWARE LINUX Linux/Unix
  • For Search and replace unix command. Linux/Unix
  • Physical Standby switchover with session active Oracle
  • move_arch_files.ksh Linux/Unix
  • handling filenname with space Linux/Unix
  • Test Case for Inserting Multiple (2.3 Million rows in 26 Seconds) Oracle
  • How can I tell if ASO is installed ? Oracle
  • Giving Grant on v$DATABASE Oracle
  • alter database backup controlfile to trace Oracle
  • kill all processes from specific user in solaris. Linux/Unix
  • 10g oem configuration Oracle
  • How to hide author name in WordPress BLOG PHP/MYSQL/Wordpress
  • Implementing Listener Security 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

  • Caching sequence in Memory Oracle
  • Rman Notes -1 Oracle
  • Renaming Global Name GLOBAL_NAME Oracle
  • load SPM baseline from cursor cache Oracle
  • longtx.sql with the flag whether session is blocking any DML locks or not. Oracle
  • DETERMINING WHICH INSTANCE OWNS WHICH SHARED MEMORY & SEMAPHORE SEGMENTS 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 (393)
  • PHP/MYSQL/Wordpress (10)
  • POSTGRESQL (0)
  • Power-BI (0)
  • Python/PySpark (7)
  • RAC (17)
  • rman-dataguard (26)
  • shell (149)
  • SQL scripts (342)
  • SQL Server (6)
  • Uncategorized (0)
  • Videos (0)

Recent Posts

  • Trace a SQL session from another session using ORADEBUG30-Sep-2025
  • 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

Archives

  • 2025
  • 2024
  • 2023
  • 2010
  • 2009
  • 2008
  • 2007
  • 2006
  • 2005
  • currwaitobj.sql SQl_ID and SQL statement you can get from currwaitobj.sql Oracle
  • How To Transfer Passwords Between Databases (ref note: 199582.1) Oracle
  • Consolidated Reference List Of Notes For Migration / Upgrade Service Requests -ID 762540.1 Oracle
  • How to choose Driver table in SQL statement Oracle
  • How to sort list of files on basis of their sizes. Linux/Unix
  • On solaris 10, “S” link is not part of $ORACLE_HOME/bin/oracle as default. ( For 9.2.0.8) Oracle
  • Looping for remote servers and find its database from oratab file. Linux/Unix
  • Set Role explaination. Oracle

Copyright © 2025 pvmehta.com.

Powered by PressBook News WordPress theme