Tuesday, 7 January 2014

Temp File issue :- ORA-01187: cannot read from file because it failed verification tests





ERROR:

ORA-01187: cannot read from file  because it failed verification tests
ORA-01110: data file 201: '/d01/ora10g/OraHome1/oradata/owcdsup/temp01.dbf'
01187. 00000 -  "cannot read from file %s because it failed verification tests"
*Cause:    The data file did not pass the checks to insure it is part of the
           database. Reads are not allowed until it is verified.
*Action:   Make the correct file available to the database. Then, either open
           the database, or execute ALTER SYSTEM CHECK DATAFILES.


Steps to Fix the issue.

Execute following queries to see above error.
select * from DBA_TEMP_FILES;

select file_name from dba_temp_files;

------------------

SELECT /* + RULE */  df.tablespace_name "Tablespace",
       df.bytes / (1024 * 1024) "Size (MB)",
       SUM(fs.bytes) / (1024 * 1024) "Free (MB)",
       Nvl(Round(SUM(fs.bytes) * 100 / df.bytes),1) "% Free",
       Round((df.bytes - SUM(fs.bytes)) * 100 / df.bytes) "% Used"
  FROM dba_free_space fs,
       (SELECT tablespace_name,SUM(bytes) bytes
          FROM dba_data_files
         GROUP BY tablespace_name) df
 WHERE fs.tablespace_name (+)  = df.tablespace_name
 GROUP BY df.tablespace_name,df.bytes
UNION ALL
SELECT /* + RULE */ df.tablespace_name tspace,
       fs.bytes / (1024 * 1024),
       SUM(df.bytes_free) / (1024 * 1024),
       Nvl(Round((SUM(fs.bytes) - df.bytes_used) * 100 / fs.bytes), 1),
       Round((SUM(fs.bytes) - df.bytes_free) * 100 / fs.bytes)
  FROM dba_temp_files fs,
       (SELECT tablespace_name,bytes_free,bytes_used
          FROM v$temp_space_header
         GROUP BY tablespace_name,bytes_free,bytes_used) df
 WHERE fs.tablespace_name (+)  = df.tablespace_name
 GROUP BY df.tablespace_name,fs.bytes,df.bytes_free,df.bytes_used
 ORDER BY 4 DESC;


Query to view existing temp file path.

Execute below query to find existing temp path .
select * from V$TEMPFILE;

Get temp file path and note it later is will be used to delete from OS and also to recreate the same file with same name.

Query to find temp tablespace name
SELECT * FROM DATABASE_PROPERTIES where PROPERTY_NAME='DEFAULT_TEMP_TABLESPACE';


Query to change default temp tablespace.

ALTER DATABASE DEFAULT TEMPORARY TABLESPACE TEMP;

Query to drop temp tablespace and datafiles
--drop tablespace temp2 including contents and datafiles;

Query to delete temp file
--ALTER DATABASE TEMPFILE '/d01/ora10g/OraHome1/oradata/temp01.dbf' DROP;
-- alter database tempfile '/d01/ora10g/OraHome1/oradata/temp01.dbf' drop including datafiles;

Also drop datafile from the OS path if it exists.

Query to add temp data file to temp tablespace.

ALTER TABLESPACE TEMP
   ADD TEMPFILE  '/d01/ora10g/OraHome1/oradata/temp01.dbf' SIZE 2G ;

Query to  Create temporary tablespace and add new datafile.
 create temporary tablespace TEMP
 tempfile '/d01/ora10g/OraHome1/oradata/temp01.dbf'
 SIZE 100M
  AUTOEXTEND ON NEXT 10M MAXSIZE UNLIMITED

No comments:

Post a Comment