Con la seguente query riusciremo a trovare le informazioni per analizare la frammentazione nelle Tablespace:
Clear Columns Computes Breaks Col Tablespace format a18 Col DFile format '99' Col MB_Totale format '999,999,999,999' Col MB_Liberi format '999,999,999,999' Col PCT_LIBERO format '900.99' Col Max_MB format '999,999,999,999,999' Col Min_MB format '999,999,999,999,999' Col Framnti format '999,999' set linesize 200 set pagesize 60 compute sum of MB_totale on report compute sum of MB_Liberi on report compute sum of Framnti on report break on report select TABLESPACE, /* Nome della Tablespace */ count(*) QT_DFile, /* Numero di Datafiles della Tablespace */ sum(BYTES_TOTALE)/1048576 MB_totale, /* Dimensione totale della Tablespace */ sum(BYTES_LIBERI)/1048576 MB_liberi, /* Spazio libero Totale della Tablespace */ (sum(BYTES_LIBERI)*100)/sum(BYTES_TOTALE) PCT_LIBERO, /*Percentuale spazio libero della Tablespace*/ max(max_bytes)/1048576 Max_MB, /* Segmento contÃguo più grande della Tablespace */ min(to_number(decode(min_bytes,0,null, min_bytes)))/1048576 Min_MB, /* Segmento contiguo più piccolo della Tablespace */ sum(Frammenti) Framnti /* Quantità di frammenti della Tablespace */ from (Select substr(a1.FILE_NAME,(instr(a1.file_name,'data/',5,1)+5),20) DataFile, a1.FILE_ID, a1.TABLESPACE_NAME TableSpace, a1.BYTES Bytes_Totale, sum(a2.bytes) Bytes_Liberi, max(a2.bytes) Max_Bytes, min(a2.bytes) Min_Bytes, count(*) Frammenti, a1.STATUS, a1.File_Name from dba_data_files a1, dba_free_space a2 where a1.file_id = a2.file_id group by a1.file_id,a1.tablespace_name,a1.bytes,a1.status,a1.file_name union Select substr(a1.FILE_NAME,(instr(a1.file_name,'data/',5,1)+5),20) DataFile, a1.FILE_ID, a1.TABLESPACE_NAME TableSpace, a1.BYTES Bytes_Totale, 0 Bytes_Liberi, 0 Max_Bytes, 0 Min_Bytes, 0 Frammenti, a1.STATUS, a1.File_Name from dba_data_files a1 where a1.file_id not in (select distinct file_id from dba_free_space) union Select substr(a1.FILE_NAME,(instr(a1.file_name,'data/',5,1)+5),20) DataFile, a1.FILE_ID, a1.TABLESPACE_NAME TableSpace, a1.BYTES Bytes_Totale, sum(a2.bytes) Bytes_Liberi, max(a2.bytes) Max_Bytes, min(a2.bytes) Min_Bytes, count(*) Frammenti, a1.STATUS, a1.File_Name from dba_temp_files a1, dba_free_space a2 where a1.file_id = a2.file_id group by a1.file_id,a1.tablespace_name,a1.bytes,a1.status,a1.file_name union Select substr(a1.FILE_NAME,(instr(a1.file_name,'data/',5,1)+5),20) DataFile, a1.FILE_ID, a1.TABLESPACE_NAME TableSpace, a1.BYTES Bytes_Totale, 0 Bytes_Liberi, 0 Max_Bytes, 0 Min_Bytes, 0 Frammenti, a1.STATUS, a1.File_Name from dba_temp_files a1 where a1.file_id not in (select distinct file_id from dba_free_space) ) group by tablespace order by pct_libero;
Esempio di risultato: