Oracle Database Control File

An Oracle Database Control file contains crucial information such as:

  • The database name
  • The timestamp of database creation
  • The names and locations of associated datafiles and redo log files
  • Tablespace information
  • Datafile offline ranges
  • The log history
  • Archived log information
  • Backup set and backup piece information
  • Backup datafile and redo log information
  • Datafile copy information
  • The current log sequence number
  • Checkpoint information

 

You can’t start the database to “MOUNT” state unless a control file exists.

Parameter CONTROL_FILE_RECORD_KEEP_TIME specifies the minimum number of days before a reusable record in the control file can be reused, the default value is 7.

An Auto-Backup control file can be set as follows:

RMAN> SHOW CONTROLFILE AUTOBACKUP;

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;

Autobackup will be triggered whenever a structural changes takes place such as adding new data file, dropping data file, renaming data file. Of course, a control backup will be included with full database backup with datafile 1 that belongs to system tablespace.

 

How to Restore database control file when it’s damaged or removed by mistake:

 

METHOD NO.1: re-creating the control file:

  1. Execute the below SQL statement to have a copy definition of the control file

SQL> alter database backup controlfile to trace as ‘C:\app\emodb\diag\rdbms\hero\hero\trace\cntl_aug5_backup.trc’;

  1. Gather information:

 

SQL>  spool gather_info

SQL>  SELECT MEMBER FROM V$LOGFILE;

SQL>  SELECT NAME FROM V$DATAFILE;

SQL>  SELECT VALUE FROM V$PARAMETER WHERE NAME = ‘control_files’;

SQL>  spool off

 

  1. Shutdown the database: SQL> shutdown immediate;

 

  1.  SQL>STARTUP NOMOUNT

 

  1. Create a new control file for the database using the CREATE CONTROLFILE statement, When creating a new control file (from trace file), specify the RESETLOGS clause if you have lost any redo log groups in addition to control files. In this case, you will need to recover from the loss of the redo logs. You must specify the RESETLOGS clause if you have renamed the database. Otherwise, select the NORESETLOGS clause.

 

 

  1. If you are creating the control file as part of recovery, recover the database. If the new control file was created using the NORESETLOGS clause you can recover the database with complete, closed database recovery.

 

  1. If you did not perform recovery, or you performed complete, closed database recovery in step open the database normally.

SQL> ALTER DATABASE OPEN;

 

 

METHOD NO.2 : RMAN

 

RMAN> list backup of controlfile;

RMAN>  SHOW CONTROLFILE AUTOBACKUP;

 

RMAN> restore controlfile from autobackup;

OR

RMAN> restore controlfile;

OR

 

Restore the controlfile from a specific autobackup file to a temporary disk location the replicate the temp controlfile to the respective locations and names given in control_files.

 RMAN> restore controlfile from ‘/tmp/c-1140771490-2008050203’ to ‘/tmp/control.tmp’;

 RMAN> replicate controlfile from ‘/tmp/control.tmp’;

Oracle ERROR ORA-28221: REPLACE not specified

I am going to simulate a scenario when an account owner would like to change the password of his account by himself.

—– as sys user or user with “DBA” role i will create an account “dropme”:

SQL> create user dropme identified by drop23_k23;

SQL> grant create session to dropme;

exit

—– i will now connect using the account “dropme” against DB1 database:

sqlplus dropme/drop23_k23@DB1

SQL> alter user dropme identified by kitk38_x9 ;

an error ORA-28221 is thrown !!!

ORA ERROR

To fix that you need to specify the old password:

SQL> alter user dropme identified by kitk38_x9 REPLACE drop23_k23;

Unfortunately some third party applications (from my experience) , the “REPLACE” command clause won’t be executed through the application (password change will be through the application) ……. How to solve that in this case ??

1. You can either grant the account “alter user” permission temporarily:

SQL> grant alter user to dropme;

OR

2. Remove the password verify function  (set it to NULL) from the profile…the user is assigned to:

SQL> ALTER PROFILE “DEFAULT” LIMIT

  SESSIONS_PER_USER UNLIMITED

  CPU_PER_SESSION UNLIMITED

  CPU_PER_CALL UNLIMITED

  CONNECT_TIME UNLIMITED

  IDLE_TIME UNLIMITED

  LOGICAL_READS_PER_SESSION UNLIMITED

  LOGICAL_READS_PER_CALL UNLIMITED

  COMPOSITE_LIMIT UNLIMITED

  PRIVATE_SGA UNLIMITED

  FAILED_LOGIN_ATTEMPTS 3

  PASSWORD_LIFE_TIME UNLIMITED

  PASSWORD_REUSE_TIME UNLIMITED

  PASSWORD_REUSE_MAX UNLIMITED

  PASSWORD_LOCK_TIME UNLIMITED

  PASSWORD_GRACE_TIME 5

  PASSWORD_VERIFY_FUNCTION NULL;