POUWIEL|COM

JeroenPouwiel

Duplicate {data/temp} filenames

With a generous wink to my esteemed colleague Remi Visser, for your (but mostly mine) Ctrl-C / Ctrl-V benefit:

SQL> SELECT SUBSTR ( file_name, INSTR( file_name, '/', -1)) file_name, COUNT(*)
  2  FROM dba_data_files
  3  GROUP BY SUBSTR ( file_name,INSTR( file_name, '/', -1)) 
  4  HAVING COUNT(*) > 1
  5  /

FILE_NAME                               COUNT(*)
------------------------------------- ----------
/****p1i005ds10.dbf                            2
/****p1i005ds11.dbf                            2

SQL>


To retrieve the complete filename, as mentioned in dba_data_files/dba_temp_files:

SQL> SELECT *
  2  FROM dba_data_files
  3  WHERE SUBSTR ( file_name, INSTR( file_name, '/', -1)) IN (
  4     SELECT file_name FROM (
  5        SELECT SUBSTR ( file_name, INSTR( file_name, '/', -1)) file_name, 
  6        COUNT(*)
  7        FROM dba_data_files
  8        GROUP BY SUBSTR ( file_name,INSTR( file_name, '/', -1))
  9        HAVING COUNT(*) > 1 )
 10     )
 11  ORDER BY 3, 1;

FILE_NAME                                                               FILE_ID
---------------------------------------------------------------------- --------
/m021/oradata/********/********p1boff00106.dbf                              153
/m001/oradata/********/********p1boff00106.dbf                              154
/m005/oradata/********/********p1boff00209.dbf                               40
/m002/oradata/********/********p1boff00209.dbf                               39
/m006/oradata/********/********p1boffis08.dbf                                52
/m004/oradata/********/********p1boffis08.dbf                               163

6 rows selected.

Comments are closed.

Categories