Professional Documents
Culture Documents
To take online backups the database should be running in Archivelog mode. To check
whether the database is running in Archivelog mode or Noarchivelog mode. Start
sqlplus and then connect as SYSDBA.
After connecting give the command "archive log list" this will show you the status
of archiving.
$ sqlplus
Enter User:/ as sysdba
SQL> ARCHIVE LOG LIST
If the database is running in archive log mode then you can take online backups.
Let us suppose we want to take online backup of "USERS" tablespace. You can query
the V$DATAFILE view to find out the name of datafiles associated with this
tablespace. Lets suppose the file is
"/u01/ica/usr1.dbf ".
Give the following series of commands to take online backup of USERS tablespace.
$ sqlplus
Enter User:/ as sysdba
SQL> alter tablespace users begin backup;
SQL> host cp /u01/ica/usr1.dbf /u02/backup
SQL> alter tablespace users end backup;
SQL> exit;
RECOVERING THE DATABASE IF IT IS RUNNING IN NOARCHIVELOG MODE
Option 1: When you don�t have a backup.
If you have lost one datafile and if you don't have any backup and if the datafile
does not contain important objects then, you can drop the damaged datafile and open
the database. You will loose all information contained in the damaged datafile.
The following are the steps to drop a damaged datafile and open the database.
(UNIX)
$ sqlplus
Enter User:/ as sysdba
SQL> STARTUP MOUNT
SQL> ALTER DATABASE DATAFILE '/u01/ica/usr1.dbf ' offline drop;
SQL> alter database open;
Option 2: When you have the Backup
If the database is running in Noarchivelog mode and if you have a full backup. Then
there are two options for you.
i . Either you can drop the damaged datafile, if it does not contain important
information which you can
afford to loose.
ii . Or you can restore from full backup. You will loose all the changes made to
the database since last full
backup.
STEP 2: Restore from full database backup i.e. copy all the files from backup to
their original locations.
(UNIX)
$ cp /u02/backup/* /u01/ica
This will copy all the files from backup directory to original destination. Also
remember to copy the control files to all the mirrored locations.
RECOVERING FROM LOST OF CONTROL FILE
If you have lost the control file and if it is mirrored. Then simply copy the
control file from mirrored location to the damaged location and open the database
If you have lost all the mirrored control files and all the datafiles and logfiles
are intact. Then you can recreate a control file.
If you have already taken the backup of control file creation statement by giving
this command. " ALTER DATABASE BACKUP CONTROLFILE TO TRACE; " and if you have not
added any tablespace since then, just create the controlfile by executing the saved
statement
Buf If you have added any new tablespace after generating create controlfile
statement. Then you have to alter the script and include the filename and size of
the file in script file.
If your script file containing the control file creation statement is "CR.SQL"
If you do not have a backup of Control file creation statement. Then you have to
manually give the CREATE CONTROL FILE statement. You have to write the file names
and sizes of all the datafiles. You will lose any datafiles which you do not
include.
Refer to "Managing Control File" topic for the CREATE CONTROL FILE statement.
Recovering Database when the database is running in ARCHIVELOG Mode
Recovering from the lost of Damaged Datafile
If you have lost one datafile. Then follow the steps shown below.
$ sqlplus
Enter User:/ as sysdba
SQL> Startup mount;
SQL> Set autorecovery on;
SQL> alter database recover;