SQL 23
BC Shrink Lobs By allan on 23rd July 2026 12:52:48 PM
  1. SET echo off
  2. SET termout off
  3. SET feedback off
  4. SET heading off
  5. SET pagesize 0
  6. SET linesize 250
  7. SET trimspool ON
  8. SET verify off
  9.  
  10. spool lobs.sql
  11.  
  12. SELECT 'alter table ' || l.owner || '.' || l.table_name ||
  13.        ' modify lob (' || l.column_name || ') (shrink space cascade); -- ' ||
  14.        round(s.bytes / 1024 / 1024, 2) || ' MB'
  15. FROM dba_lobs l
  16. JOIN dba_segments s
  17.   ON s.tablespace_name = l.tablespace_name
  18.  AND s.owner = l.owner
  19.  AND s.segment_type = 'LOBSEGMENT'
  20. WHERE l.owner = 'SYS'
  21.   AND l.tablespace_name = 'SYSAUX'
  22.   AND l.table_name LIKE 'WR%'
  23. ORDER BY s.bytes
  24. /
  25.  
  26. spool off
  27. SET termout ON

Paste is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.