SQL 7
Sel tbls By allan on 1st October 2025 11:06:08 AM
  1. SET LINES 1000
  2. SET pages 1000
  3.  
  4. COLUMN c1 heading "Tablespace"      format a25
  5. COLUMN c2 heading "Allocated MB"    format 999999999999
  6. COLUMN c3 heading "Used MB"         format 999999999999
  7. COLUMN c4 heading "Free MB"         format 999999999999
  8. COLUMN c5 heading "Used"            format 999999999999.00
  9. COLUMN c6 heading "Data Files"      format 999
  10.  
  11. ACCEPT TABLESPACE_NAME CHAR DEFAULT '' PROMPT 'Enter tablespace name: '
  12.  
  13. define TABLESPACE_NAME='&TABLESPACE_NAME';
  14.  
  15. SELECT nvl(b.tablespace_name, nvl(a.tablespace_name,'UNKNOWN')) c1,
  16.          kbytes_alloc c2,
  17.          kbytes_alloc-nvl(kbytes_free,0) c3,
  18.          nvl(kbytes_free,0) c4,
  19.          ((kbytes_alloc-nvl(kbytes_free,0))/kbytes_alloc) c5,
  20.          data_files c6
  21. FROM ( SELECT SUM(bytes)/1024/1024 Kbytes_free,
  22.                           MAX(bytes)/1024/1024 largest,
  23.                           tablespace_name
  24.                  FROM sys.dba_free_space
  25.                 GROUP BY tablespace_name ) a,
  26.          ( SELECT SUM(bytes)/1024/1024 Kbytes_alloc,
  27.                           tablespace_name,
  28.                           COUNT(*) data_files
  29.                  FROM sys.dba_data_files
  30.                 GROUP BY tablespace_name )b
  31. WHERE a.tablespace_name (+) = b.tablespace_name
  32.         AND ('&TABLESPACE_NAME' IS NULL OR instr(LOWER(b.tablespace_name),LOWER('&TABLESPACE_NAME')) > 0)
  33. ORDER BY 1                                                         
  34. /

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.