Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 37

1

Oracle Database backup & Recovery Questions

1.What are the types of incomplete media recovery available in oracle database?
Following were the types of incomplete media recovery available in oracle database. we will see each of the
in detail in respective posts.
Time based recovery
Log sequence recovery
Change based recovery (SCN)
Cancel based recovery

2.What is Time Based Recovery in Oracle database?


Recover the database to a particular specified time and opening the database with resetlog option.

3.What is Log Sequence Recovery in Oracle database?


Recovery the databases to a particular online redo log file sequence number and after recovering to a
specified sequence number database are opened with resetlog option.

4.What is Change Based Recovery (SCN) in Oracle database?


This type of recovery used when end user need of recovering the database to particular commit of
transaction. In this type of recovery SCN number is important to recover to a particular point.

5.What is Cancel Based Recovery in Oracle database?


Mostly used incomplete recovery and this is the only option if what time, what log sequence number or what
SCN the database needed to recover. After recovering database, it must open only with the resetlog option.

Following are the different questions and answers regarding Backup and Recovery (RMAN) of Oracle
Database.

6.How often should backup oracle database?


Backup strategy purely depends upon the business need. If no down time then database should run in
ARCHIVE mode and frequent (daily) backup is needed. If down time is there and lose of data won’t affect
business then database can run in NOARCHIVE mode and infrequent backup can be made.
If downtime is ok and lose of datafiles won’t affect the business then database backup can be done at
infrequent time and database can be run in NOARCHIVE mode.
Factors regarding this backup strategy
Utilization of oracle resource is less for backup.
Increase in recovery time and lose of data.
Business should run with no downtime then frequent inconsistent backup needed(daily backup), multiplex
online redo log files (maintaining multiple copies), different location for archive redo log files and database
must run in ARCHIVE mode and Dataguard can be implemented to make less down time during recovery.

7.What is consistent backup in oracle database?


A full backup of the database or backup of one or more datafiles from database after making the database to
a clean shutdown(NORMAL or IMMEDIATE) ie all datafiles and controlfiles are checkpointed to same SCN.

8.How consistent backups are taken?


Consistent backups are taken after making database SHUTDOWN with NORMAL or IMMEDIATE options.
Backup taking after SHUTDOWN ABORT is a inconsistent backup because this backup once restored need
instance recovery.
Databases in NOARCHIVE mode has only consistent backup as backup options.
Advantage of consistent backup
Instance recovery and media recovery are not required during restore and recovery of consistent backup.
No needs to apply redo log files after restoring datafiles because they are consistent while taking backup
Important factors in consistent backup
Consistent backup are taken only when database is closed cleanly.
Consistent backup are mostly used with database in NOARCHIVE mode.
2
In consistent backup all the online and rewrite datafiles are not in FUZZY state.
Oracle checks the restore backup is consistent by comparing the SCN in the datafile header SCN with the
SCN of datafile header information available in control file.
Tablespaces which are read only state has older SCN but still they are consistent with the other datafiles in
database which has current SCN.
Checkpoint is the process which makes the datafiles and controlfile consistent.
For every commit occurring in the database SCN will get incremented by 1
Important points in recovery using consistent backup
Always use backup controlfile for restoring consistent backup.
When current controlfile was used for restoring consistent backup then need to apply redo files to the point in
time recovery.
During recovery, current controlfile is used with consistent backup instead of backup controlfile then oracle
begins the media recovery at the lowest SCN in the datafile header.

9.What is tablespace backup in oracle database?


Tablespace backup is backuping up all datafiles of particular tablespace’s for which backup is made to
backup location.
Example:
Tablespace users contains datafiles 4, 6, 9 with it, then tablespace backup of users tablespace’s is
backuping all the 3 datafiles to remote location.
Tablespace backup depends on tablespace state and database state, they are as follows,
Tablespace is in offline, online or read only.
Database is in archivelog mode or noarchive log mode.
Both above two factors are interdependent.
If database is in archivelog mode, then tablespace backup can be made when the tablespace was in any one
of the following state i.e online, offline or read-only. Because redo and archive log files are required to make
this backup consistent with other tablespaces.
If the database is in noarchive log mode, then tablespace must be in offline-normal or read-only. Because
redo and archive log files are not required because they are not available when database is in no archive
mode.

10.What is full database backup in oracle?


Full database backup means backuping all the datafiles and controlfiles of the database to the backup
location for future restore.
Full database backup can be taken in both archivelog mode and noarchivelog mode.
If database is running in archive log mode then full database backup can be done while database is up and
running or down and not running.
If database is running in noarchive log mode then full database backup done while database is down and not
running.
Full database backup can be made in both consistence and inconsistence backup.
In noarchive mode full database backup was always consistence backup.
In archive log mode full database backup may be inconsistence and made it consistent by applying online
redo log files and archive redo logs files.

11.What is datafile backup in oracle database?


Datafile backup is process of backing up single datafile at a time.
In archive mode
Backuping single datafile from a tablespace and backups are valid and works only when the database is
running in archivelog mode.
In noarchive mode
In this mode this backups are valid when all the datafiles from a tablespace are taken backup and also
tablespace should be in offline-normal or read-only.
Mostly this type of backup is not used when the database is in noarchive mode and instead of this method
talbespace backup is used.

12.What is inconsistent closed backup in oracle database?


3
Inconsistent backup are backup taken when all the read-write datafiles and controlfiles are not checkpointed
to same SCN.
Database was closed with SHUTDOWN ABORT or SYSTEM(server) failure, then backup taken after this
are inconsistent, because datafile headers of backed up datafiles contain different SCN’s and require to
apply redo log files during restore and recovery that is not possible in NOARCHIVE mode database with no
archived redo log files.
That’s why oracle recommends do not make inconsistent closed backup when database is running in
NOARCHIVE mode.

13.When we go for inconsistent backups?


When we need to run the database with no downtime, then put the database in archivelog mode and go with
inconsistent backup.
Do not take inconsistent closed backup when database is running in NOARCHIVELOG mode.
When database is running in NOARCHIVE mode then closed the database with SHUTDOWN NORMAL or
SHUTDOWN IMMEDIATE and do a consistent backup.
In this inconsistent backup type, the datafiles headers have inconsistent SCN and also the datafile header of
the online datafile and offline datafile have inconsistent SCN number this can be recovered (made
consistent) by applying redo log files.

14.How inconsistent backups are made in oracle database?


Each Datafiles are backed up at different time, so they have different SCN among them ie why they are
inconsistent backups. They are made consistent by applying archive log files and online redo log files during
recovery.

15.What is redundancy set in oracle database?


Redundancy set in oracle database is set of files needed for recovery of database during failure. They are as
follows, Control file, Datafiles & online redo log.
Golden rule in maintaining redundancy set are as follows,
The disk or media maintaining the redundancy set should be sperate from the disk that contain
online redo log files, control file and datafiles.
Why above condition was when disk contain datafiles crash then we can use the redundancy set stored in
different disk or media to restore and recovery the database. If we maintain the datafiles and redundancy set
in same disk then failure of disk cause to lose both datafiles and redundancy set and no redundancy set will
be there for recovery, so please avoid this.

16.What is tablespace backup in oracle database?


Tablespace backup is backuping up all datafiles of particular tablespaces for which backup is made to
backup location.
Example:
Tablespace users contains datafiles 4,6,9 with it, then tablespace backup of users tablespaces is backuping
all the 3 datafiles to remote location.
Tablespace backup depends on tablespace state and database state, they are as follows,
Tablespace is in offline, online or read only.
Database is in archivelog mode or noarchive log mode.
Both above two factors are interdependent.
If database is in archivelog mode, then tablespace backup can be made when the tablespace was in any one
of the following state i.e online, offline or read-only. Because redo and archive log files are required to make
this backup consistent with other tablespaces.
If the database is in noarchive log mode, then tablespace must be in offline-normal or read-only. Because
redo and archive log files are not required because they are not available when database is in no archive
mode.

17.What is full database backup in oracle?


Full database backup means backuping all the datafiles and controlfiles of the database to the backup
location for future restore.
Full database backup can be taken in both archivelog mode and noarchivelog mode.
4
If database is running in archive log mode then full database backup can be done while database is up and
running or down and not running.
If database is running in noarchive log mode then full database backup done while database is down and not
running.
Full database backup can be made in both consistence and inconsistence backup.
In noarchive mode full database backup was always consistence backup.
In archive log mode full database backup may be inconsistence and made it consistent by applying online
redo log files and archive redo logs files.

18.What is datafile backup in oracle database?


Datafile backup is process of backing up single datafile at a time.
In archive mode
Backuping single datafile from a tablespace and backups are valid and works only when the database is
running in archivelog mode.
In noarchive mode
In this mode this backups are valid when all the datafiles from a tablespace are taken backup and also
tablespace should be in offline-normal or read-only.
Mostly these types of backup are not used when the database is in noarchive mode and instead of this
method talbespace backup is used.

19.What is controlfile backup in oracle database?


Controlfile backup are made when the database is running in archive log mode and database is up and
running.
If database is running in noarchive log mode then controlfile backup are made when the database is
mounted and not opened.
Types of format in controlfile backup
Binary format
In this format controlfile backup are made as a replica of orginal controlfile to a backup location ie all the
details present in controlfile will be present in backup controlfile.
Trace file format
In this only script for recreation of controlfile will be got as a trace file in udump. No details like RMAN
backupdetails, SCN number detail, archive log locations and online redolog file sequence no. Only location of
datafiles and redo log files will got as script to recreate the controlfile.

20.What are all types of failures in oracle database?


Following are the types of failure happen in oracle database which makes you to loss or corrupt data.
Failure Type Reason

Statement failure Logical failure in handling a sql statement.

Process failure Session failure due to network or abnormal termination of oracle server process.

Failure of database functioning like SGA and background process are unable
Instance failure
continue functioning in the server due server problem

Physical problem like disk crash makes datafile unavailable or unaccessble to


Media failure
oracle database.
User or Application
Loss of data like end user accidentally deleted important datas.
error

21.What is a rollback segment in oracle database?


Every database has rollback segments which are used to store pre-image of the modified records that’s
when a records gets updated or deleted then its pre-image copies that information before change will be
5
stored in this rollback segments.

22.What is the use of rollback segments?


Following were the use of the rollback segments
To store the pre-image of the records modified by uncommitted transactions for other session to query the
records without any delay.
Used with oracle recovery to make the database consistence by recovering any uncommitted transactions.

23.When all we need to backup current controlfile?


When following any one structure changes happen then it is mandatory to take backup of the controlfile to
reflect the current database structural changes.
Adding datafiles
Dropping datafiles
Adding online redo log files
Dropping online redo log files
Adding tablespace
Dropping tablespace

24.What are the files need to backup in oracle database?


Following components of the database were needed for backup and recovery
Controlfile – mandatory – but can be recreated
datafiles – mandatory – no other go
online redo log files – instance recovery
archive log files – recovery master

25.How to migrate Oracle database across OS platform using RMAN?


To migrate Oracle database from one Operating system platform to another Operating System platform by
using following RMAN command.
CONVERT DATABASE ON TARGET DATABASE

26.What is the difference between recovery and restoring of the database?


- Restoring a database is the replacement of lost or damaged file with a backup.
- You can restore files either with operating system commands as UNIX cp or the RMAN RESTORE
COMMAND.
- Recovering a database is the application of redo data or incremental backups to database files in order to
reconstruct lost changes.
- The three types of recovery are instance recovery, crash recovery and media recovery.
- Oracle performs the first two types of recovery automatically using online redo records; only media recovery
requires you to restore a backup and issue commands. Only Recovery Manager can recover data files by
applying incremental backups.

27. What are the different tools are available for hot backup? Is it preferable to take it manually all the time or
it depends on the size of the database? 
- hot backup(online backup): A backup of one or more data files taken while a database is open and the
datafiles are online
- user-managed backup while the database is open: first must put the tablespace in backup mode by issuing an
ALTER TABLESPACE BEGIN BACKUP command
- RMAN backup: do not need to put the tablespace in backup mode
- OEM
- (cited): if the database size in TB the RMAN backup will take more than 10 hours to complete
- special backup techniques which are given by vendors like TIVOLI and Netbackup:
Business content Volume Sync which copies a snapshot of the primary data to another place and backup the
database from one SAN to another within 15 min for 2TB of database and is the preferable method for big
company
6

28. What is the difference between media recovery and crash recovery
Ans: Media recovery is the application of redo or incremental backups to a restored backup datafile or
individual data block to bring it to a specified time.
- Datafile media recovery always begins at the lowest SCN recorded in the datafile headers.
- when perform media recovery, you an recover:
* The whole database
* A tablespace
* A datafile
* A set of blocks within a datafile
- Typically, you perform media recovery after a media failure damages some or all of the database files
crash recovery is the automatic application of online redo records to a database after either a single-instance
database crashes or all instances of an Oracle Real Application Cluster configuration crash. Crash recovery
only requires redo from the online logs: archive redo logs are not required

29. What are the steps involved in Database startup? 


Ans: steps are:
Nomount stage (start an instance)
- read initialization parameter file
- SGA is allocated
- background process are started
- alert log file is opened
Mount stage
- control files is read
- name & location of the datafiles, logfiles are detected
Open stage
- opens the online datafiles and online redo log files.
- note: If a tablespace was offline when the database was previously shut down, the tablespace and its
corresponding datafiles will still be offline when you reopen the database.

30. What are steps involved in database shutdown?


ans: (1) Close the database
- Oracle writes all database data and recovery data in the SGA to the datafiles and redo log files, respectively.
- Next, Oracle closes all online datafiles and online redo log files.
(2) Unmount the database
- After the database is closed, Oracle unmounts the database to disassociate it from the instance. - At this
point, the instance remains in the memory of your computer.
- After a database is unmounted, Oracle closes the control files of the database.
(3) Shutdown the instance
- SGA is removed from memory and the background processes are terminated.

31.Why and when should I backup my database?


Backup and recovery is one of the most important aspects of a DBA's job. If you lose your company's data,
you could very well lose your job. Hardware and software can always be replaced, but your data may be
irreplaceable!
Normally one would schedule a hierarchy of daily, weekly and monthly backups, however consult with your
users before deciding on a backup schedule. Backup frequency normally depends on the following factors:
Rate of data change/ transaction rate
Database availability/ Can you shutdown for cold backups?
Criticality of the data/ Value of the data to the company
Read-only tablespace needs backing up just once right after you make it read-only
7
If you are running in archivelog mode you can backup parts of a database over an extended cycle of days
If archive logging is enabled one needs to backup archived log files timeously to prevent database freezes
Etc.
Carefully plan backup retention periods. Ensure enough backup media (tapes) are available and that old
backups are expired in-time to make media available for new backups. Off-site vaulting is also highly
recommended.
Frequently test your ability to recover and document all possible scenarios. Remember, it's the little things that
will get you. Most failed recoveries are a result of organizational errors and miscommunication.

32.What strategies are available for backing-up an Oracle database?


The following methods are valid for backing-up an Oracle database:
Export/Import - Exports are "logical" database backups in that they extract logical definitions and data from
the database to a file. See the Import/ Export FAQ for more details.
Cold or Off-line Backups - shut the database down and backup up ALL data, log, and control files.
Hot or On-line Backups - If the databases is available and in ARCHIVELOG mode, set the tablespaces into
backup mode and backup their files. Also remember to backup the control files and archived redo log files.
RMAN Backups - while the database is off-line or on-line, use the "rman" utility to backup the database.
It is advisable to use more than one of these methods to backup your database. For example, if you choose to
do on-line database backups; also cover yourself by doing database exports. Also test ALL backup and
recovery scenarios carefully. It is better to be safe than sorry.
Regardless of your strategy, also remember to backup all required software libraries, parameter files,
password files, etc. If your database is in ARCHIVELOG mode, you also need to backup archived log files.

33.What is the difference between online and offline backups?


A hot (or on-line) backup is a backup performed while the database is open and available for use (read and
write activity). Except for Oracle exports, one can only do on-line backups when the database is
ARCHIVELOG mode.
A cold (or off-line) backup is a backup performed while the database is off-line and unavailable to its users.
Cold backups can be taken regardless if the database is in ARCHIVELOG or NOARCHIVELOG mode.
It is easier to restore from off-line backups as no recovery (from archived logs) would be required to make the
database consistent. Nevertheless, on-line backups are less disruptive and don't require database downtime.
Point-in-time recovery (regardless if you do on-line or off-line backups) is only available when the database is
in ARCHIVELOG mode.

34.What is the difference between restoring and recovering?


Restoring involves copying backup files from secondary storage (backup media) to disk. This can be done to
replace damaged files or to copy/move a database to a new location.
Recovery is the processes of applying redo logs to the database to roll it forward. One can roll-forward until a
specific point-in-time (before the disaster occurred), or roll-forward until the last transaction recorded in the
log files.
SQL> connect SYS as SYSDBA
SQL> RECOVER DATABASE UNTIL TIME '2001-03-06:16:00:00' USING BACKUP CONTROLFILE;
RMAN> run {
set until time to_date('04-Aug-2004 00:00:00', 'DD-MON-YYYY HH24:MI:SS');
restore database;
recover database;
}

35.My database is down and I cannot restore. What now?


This is probably not the appropriate time to be sarcastic, but, recovery without backups is not supported. You
know that you should have tested your recovery strategy, and that you should always backup a corrupted
8
database before attempting to restore/recover it.
Nevertheless, Oracle Consulting can sometimes extract data from an offline database using a utility called
DUL (Disk UnLoad - Life is DUL without it!). This utility reads data in the data files and unloads it into
SQL*Loader or export dump files. Hopefully you'll then be able to load the data into a working database.
Note that DUL does not care about rollback segments, corrupted blocks, etc, and can thus not guarantee that
the data is not logically corrupt. It is intended as an absolute last resort and will most likely cost your
company a lot of money!
DUDE (Database Unloading by Data Extraction) is another non-Oracle utility that can be used to extract data
from a dead database. More info about DUDE is available at http://www.ora600.nl/.

36.How does one backup a database using the export utility?


Oracle exports are "logical" database backups (not physical) as they extract data and logical definitions from
the database into a file. Other backup strategies normally back-up the physical data files.
One of the advantages of exports is that one can selectively re-import tables; however one cannot roll-forward
from a restored export. To completely restore a database from an export file one practically needs to recreate
the entire database.
Always do full system level exports (FULL=YES). Full exports include more information about the database
in the export file than user level exports. For more information about the Oracle export and import utilities,
see the Import/ Export FAQ.

37.How does one put a database into ARCHIVELOG mode?


The main reason for running in archivelog mode is that one can provide 24-hour availability and guarantee
complete data recoverability. It is also necessary to enable ARCHIVELOG mode before one can start to use
on-line database backups.
Issue the following commands to put a database into ARCHIVELOG mode:
SQL> CONNECT sys AS SYSDBA
SQL> STARTUP MOUNT EXCLUSIVE;
SQL> ALTER DATABASE ARCHIVELOG;
SQL> ARCHIVE LOG START;
SQL> ALTER DATABASE OPEN;
Alternatively, add the above commands into your database's startup command script, and bounce the database.
The following parameter needs to be set for databases in ARCHIVELOG mode:
log_archive_start = TRUE
log_archive_dest_1 = 'LOCATION=/arch_dir_name'
log_archive_dest_state_1 = ENABLE
log_archive_format = %d_%t_%s.arc
NOTE 1: Remember to take a baseline database backup right after enabling archivelog mode. Without it one
would not be able to recover. Also, implement an archivelog backup to prevent the archive log directory from
filling-up.
NOTE 2:' ARCHIVELOG mode was introduced with Oracle 6, and is essential for database point-in-time
recovery. Archiving can be used in combination with on-line and off-line database backups.
NOTE 3: You may want to set the following INIT.ORA parameters when enabling ARCHIVELOG
mode: log_archive_start=TRUE, log_archive_dest=..., and log_archive_format=...
NOTE 4: You can change the archive log destination of a database on-line with the ARCHIVE LOG START
TO 'directory'; statement. This statement is often used to switch archiving between a set of directories.
NOTE 5: When running Oracle Real Application Clusters (RAC), you need to shut down all nodes before
changing the database to ARCHIVELOG mode. See the RAC FAQ for more details.

38.I've lost an archived/online REDO LOG file; can I get my DB back?


The following INIT.ORA/SPFILE parameter can be used if your current redologs are corrupted or blown
away. It may also be handy if you do database recovery and one of the archived log files are missing and
9
cannot be restored.
NOTE: Caution is advised when enabling this parameter as you might end-up losing your entire database.
Please contact Oracle Support before using it.
_allow_resetlogs_corruption = true
This should allow you to open the database. However, after using this parameter your database will be
inconsistent (some committed transactions may be lost or partially applied).
Steps:
Do a "SHUTDOWN NORMAL" of the database
Set the above parameter
Do a "STARTUP MOUNT" and "ALTER DATABASE OPEN RESETLOGS;"
If the database asks for recovery, use an UNTIL CANCEL type recovery and apply all available archive and
on-line redo logs, then issue CANCEL and reissue the "ALTER DATABASE OPEN RESETLOGS;"
command.
Wait a couple of minutes for Oracle to sort itself out
Do a "SHUTDOWN NORMAL"
Remove the above parameter!
Do a database "STARTUP" and check your ALERT.LOG file for errors.
Extract the data and rebuild the entire database

User managed backup and recovery


This section deals with user managed, or non-RMAN backups.

39.How does one do off-line database backups?


Shut down the database from sqlplus or server manager. Backup all files to secondary storage (eg. tapes).
Ensure that you backup all data files, all control files and all log files. When completed, restart your database.
Do the following queries to get a list of all files that needs to be backed up:
select name from sys.v_$datafile;
select member from sys.v_$logfile;
select name from sys.v_$controlfile;
Sometimes Oracle takes forever to shutdown with the "immediate" option. As workaround to this problem,
shutdown using these commands:
alter system checkpoint;
shutdown abort
startup restrict
shutdown immediate
Note that if your database is in ARCHIVELOG mode, one can still use archived log files to roll forward from
an off-line backup. If you cannot take your database down for a cold (off-line) backup at a convenient time,
switch your database into ARCHIVELOG mode and perform hot (on-line) backups.

40.How does one do on-line database backups?


Each tablespace that needs to be backed-up must be switched into backup mode before copying the files out to
secondary storage (tapes). Look at this simple example.
ALTER TABLESPACE xyz BEGIN BACKUP;
! cp xyzFile1 /backupDir/
ALTER TABLESPACE xyz END BACKUP;
It is better to backup tablespace for tablespace than to put all tablespaces in backup mode. Backing them up
separately incurs less overhead. When done, remember to backup your control files. Look at this example:
ALTER SYSTEM SWITCH LOGFILE; -- Force log switch to update control file headers
ALTER DATABASE BACKUP CONTROLFILE TO '/backupDir/control.dbf';
NOTE: Do not run on-line backups during peak processing periods. Oracle will write complete database
blocks instead of the normal deltas to redo log files while in backup mode. This will lead to excessive
10
database archiving and even database freezes.

41. My database was terminated while in BACKUP MODE, do I need to recover?


If a database was terminated while one of its tablespaces was in BACKUP MODE (ALTER TABLESPACE
xyz BEGIN BACKUP;), it will tell you that media recovery is required when you try to restart the database.
The DBA is then required to recover the database and apply all archived logs to the database. However, from
Oracle 7.2, one can simply take the individual datafiles out of backup mode and restart the database.
ALTER DATABASE DATAFILE '/path/filename' END BACKUP;
One can select from V$BACKUP to see which datafiles are in backup mode. This normally saves a significant
amount of database down time. See script end_backup2.sql in the Scripts section of this site.
From Oracle9i onwards, the following command can be used to take all of the datafiles out of hotbackup
mode:
ALTER DATABASE END BACKUP;
This command must be issued when the database is mounted, but not yet opened.

42.Does Oracle write to data files in begin/hot backup mode?


When a tablespace is in backup mode, Oracle will stop updating its file headers, but will continue to write to
the data files.
When in backup mode, Oracle will write complete changed blocks to the redo log files. Normally only deltas
(change vectors) are logged to the redo logs. This is done to enable reconstruction of a block if only half of it
was backed up (split blocks). Because of this, one should notice increased log activity and archiving during
on-line backups.
To solve this problem, simply switch to RMAN backups.

RMAN backup and recovery


This section deals with RMAN backups:

43.What is RMAN and how does one use it?


Recovery Manager (or RMAN) is an Oracle provided utility for backing-up, restoring and recovering Oracle
Databases. RMAN ships with the database server and doesn't require a separate installation. The RMAN
executable is located in your ORACLE_HOME/bin directory.
In fact RMAN, is just a Pro*C application that translates commands to a PL/SQL interface. The PL/SQL calls
are statically linked into the Oracle kernel, and does not require the database to be opened (mapped from
the ?/rdbms/admin/recover.bsq file).
RMAN can do off-line and on-line database backups. It cannot, however, write directly to tape, but various
3rd-party tools (like Veritas, Omiback, etc) can integrate with RMAN to handle tape library management.
RMAN can be operated from Oracle Enterprise Manager, or from command line. Here are the command line
arguments:
Argument Value Description
-----------------------------------------------------------------------------
target quoted-string connect-string for target database
catalog quoted-string connect-string for recovery catalog
nocatalog none if specified, then no recovery catalog
cmdfile quoted-string name of input command file
log quoted-string name of output message log file
trace quoted-string name of output debugging message log file
append none if specified, log is opened in append mode
debug optional-args activate debugging
msgno none show RMAN-nnnn prefix for all messages
send quoted-string send a command to the media manager
pipe string building block for pipe names
11
timeout integer number of seconds to wait for pipe input
-----------------------------------------------------------------------------
Here is an example:
[oracle@localhost oracle]$ rman
Recovery Manager: Release 10.1.0.2.0 - Production
Copyright (c) 1995, 2004, Oracle. All rights reserved.

RMAN> connect target;

connected to target database: ORCL (DBID=1058957020)

RMAN> backup database;


...
44.How does one backup and restore a database using RMAN?
The biggest advantage of RMAN is that it only backup used space in the database. RMAN doesn't put
tablespaces in backup mode, saving on redo generation overhead. RMAN will re-read database blocks until it
gets a consistent image of it. Look at this simple backup example.
rman target sys/*** nocatalog
run {
allocate channel t1 type disk;
backup
format '/app/oracle/backup/%d_t%t_s%s_p%p'
(database);
release channel t1;
}
Example RMAN restore:
rman target sys/*** nocatalog
run {
allocate channel t1 type disk;
# set until time 'Aug 07 2000 :51';
restore tablespace users;
recover tablespace users;
release channel t1;
}
The examples above are extremely simplistic and only useful for illustrating basic concepts. By default Oracle
uses the database controlfiles to store information about backups. Normally one would rather setup a RMAN
catalog database to store RMAN metadata in. Read the Oracle Backup and Recovery Guide before
implementing any RMAN backups.
Note: RMAN cannot write image copies directly to tape. One needs to use a third-party media manager that
integrates with RMAN to backup directly to tape. Alternatively one can backup to disk and then manually
copy the backups to tape.

45.How does one backup and restore archived log files?


One can backup archived log files using RMAN or any operating system backup utility. Remember to delete
files after backing them up to prevent the archive log directory from filling up. If the archive log directory
becomes full, your database will hang! Look at this simple RMAN backup scripts:
RMAN> run {
2> allocate channel dev1 type disk;
3> backup
4> format '/app/oracle/archback/log_%t_%sp%p'
5> (archivelog all delete input);
12
6> release channel dev1;
7> }
The "delete input" clause will delete the archived logs as they are backed-up.
List all archivelog backups for the past 24 hours:
RMAN> LIST BACKUP OF ARCHIVELOG FROM TIME 'sysdate-1';
Here is a restore example:
RMAN> run {
2> allocate channel dev1 type disk;
3> restore (archivelog low logseq 78311 high logseq 78340 thread 1 all);
4> release channel dev1;
5> }

46.How does one create a RMAN recovery catalog?


Start by creating a database schema (usually called rman). Assign an appropriate tablespace to it and grant it
the recovery_catalog_owner role. Look at this example:
sqlplus sys
SQL> create user rman identified by rman;
SQL> alter user rman default tablespace tools temporary tablespace temp;
SQL> alter user rman quota unlimited on tools;
SQL> grant connect, resource, recovery_catalog_owner to rman;
SQL> exit;
Next, log in to rman and create the catalog schema. Prior to Oracle 8i this was done by running
the catrman.sql script.
rman catalog rman/rman
RMAN> create catalog tablespace tools;
RMAN> exit;
You can now continue by registering your databases in the catalog. Look at this example:
rman catalog rman/rman target backdba/backdba
RMAN> register database;
One can also use the "upgrade catalog;" command to upgrade to a new RMAN release, or the "drop catalog;"
command to remove an RMAN catalog. These commands need to be entered twice to confirm the operation.

47.How does one integrate RMAN with third-party Media Managers?


The following Media Management Software Vendors have integrated their media management software with
RMAN (Oracle Recovery Manager):
Veritas NetBackup - http://www.veritas.com/
EMC Data Manager (EDM) - http://www.emc.com/
HP OMNIBack/ DataProtector - http://www.hp.com/
IBM's Tivoli Storage Manager (formerly ADSM) - http://www.tivoli.com/storage/
EMC Networker - http://www.emc.com/
BrightStor ARCserve Backup - http://www.ca.com/us/data-loss-prevention.aspx
Sterling Software's SAMS:Alexandria (formerly from Spectralogic) - http://www.sterling.com/sams/
SUN's Solstice Backup - http://www.sun.com/software/whitepapers/backup-n-storage/
CommVault Galaxy - http://www.commvault.com/
etc...
The above Media Management Vendors will provide first line technical support (and installation guides) for
their respective products.
A complete list of supported Media Management Vendors can be found
at: http://www.oracle.com/technology/deploy/availability/htdocs/bsp.htm
When allocating channels one can specify Media Management spesific parameters. Here are some examples:
Netbackup on Solaris:
13
allocate channel t1 type 'SBT_TAPE' PARMS='SBT_LIBRARY=/usr/openv/netbackup/bin/libobk.so.1';
Netbackup on Windows:
allocate channel t1 type 'SBT_TAPE' send "NB_ORA_CLIENT=client_machine_name";
Omniback/ DataProtector on HP-UX:
allocate channel t1 type 'SBT_TAPE' PARMS='SBT_LIBRARY= /opt/omni/lib/libob2oracle8_64bit.sl';
or:
allocate channel 'dev_1' type 'sbt_tape' parms
'ENV=OB2BARTYPE=Oracle8,OB2APPNAME=orcl,OB2BARLIST=machinename_orcl_archlogs)';

48.How does one clone/duplicate a database with RMAN?


The first step to clone or duplicate a database with RMAN is to create a new INIT.ORA and password file
(use the orapwd utility) on the machine you need to clone the database to. Review all parameters and make
the required changed. For example, set the DB_NAME parameter to the new database's name.
Secondly, you need to change your environment variables, and do a STARTUP NOMOUNT from sqlplus.
This database is referred to as the AUXILIARY in the script below.
Lastly, write a RMAN script like this to do the cloning, and call it with "rman cmdfile dupdb.rcv":
connect target sys/secure@origdb
connect catalog rman/rman@catdb
connect auxiliary /

run {
set newname for datafile 1 to '/ORADATA/u01/system01.dbf';
set newname for datafile 2 to '/ORADATA/u02/undotbs01.dbf';
set newname for datafile 3 to '/ORADATA/u03/users01.dbf';
set newname for datafile 4 to '/ORADATA/u03/indx01.dbf';
set newname for datafile 5 to '/ORADATA/u02/example01.dbf';

allocate auxiliary channel dupdb1 type disk;


set until sequence 2 thread 1;

duplicate target database to dupdb


logfile
GROUP 1 ('/ORADATA/u02/redo01.log') SIZE 200k REUSE,
GROUP 2 ('/ORADATA/u03/redo02.log') SIZE 200k REUSE;
}
The above script will connect to the "target" (database that will be cloned), the recovery catalog (to get
backup info), and the auxiliary database (new duplicate DB). Previous backups will be restored and the
database recovered to the "set until time" specified in the script.
Notes: the "set newname" commands are only required if your datafile names will different from the target
database.
The newly cloned DB will have its own unique DBID.

49.Can one restore RMAN backups without a CONTROLFILE and RECOVERY CATALOG?
Details of RMAN backups are stored in the database control files and optionally a Recovery Catalog. If both
these are gone, RMAN cannot restore the database. In such a situation one must extract a control file (or other
files) from the backup pieces written out when the last backup was taken. Let's look at an example:
Let's take a backup (partial in our case for ilustrative purposes):
$ rman target / nocatalog
Recovery Manager: Release 10.1.0.2.0 - 64bit Production
Copyright (c) 1995, 2004, Oracle. All rights reserved.
14
connected to target database: ORCL (DBID=1046662649)
using target database controlfile instead of recovery catalog

RMAN> backup datafile 1;

Starting backup at 20-AUG-04


allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=146 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/oradata/orcl/system01.dbf
channel ORA_DISK_1: starting piece 1 at 20-AUG-04
channel ORA_DISK_1: finished piece 1 at 20-AUG-04
piece handle=
/flash_recovery_area/ORCL/backupset/2004_08_20/o1_mf_nnndf_TAG20040820T153256_0lczd9tf_.bkp
comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current controlfile in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 20-AUG-04
channel ORA_DISK_1: finished piece 1 at 20-AUG-04
piece handle=
/flash_recovery_area/ORCL/backupset/2004_08_20/o1_mf_ncsnf_TAG20040820T153256_0lczfrx8_.bkp
comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:04
Finished backup at 20-AUG-04[/code]

Now, let's destroy one of the control files:

SQL> show parameters CONTROL_FILES


NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_files string /oradata/orcl/control01.ctl,
/oradata/orcl/control02.ctl,
/oradata/orcl/control03.ctl
SQL> shutdown abort;
ORACLE instance shut down.
SQL> ! mv /oradata/orcl/control01.ctl /tmp/control01.ctl</pre>

Now, let's see if we can restore it. First we need to start the databaase in NOMOUNT mode:

SQL> startup NOMOUNT


ORACLE instance started.

Total System Global Area 289406976 bytes


Fixed Size 1301536 bytes
Variable Size 262677472 bytes
Database Buffers 25165824 bytes
Redo Buffers 262144 bytes</pre>
15
Now, from SQL*Plus, run the following PL/SQL block to restore the file:
DECLARE
v_devtype VARCHAR2(100);
v_done BOOLEAN;
v_maxPieces NUMBER;

TYPE t_pieceName IS TABLE OF varchar2(255) INDEX BY binary_integer;


v_pieceName t_pieceName;
BEGIN
-- Define the backup pieces... (names from the RMAN Log file)
v_pieceName(1) :=

'/flash_recovery_area/ORCL/backupset/2004_08_20/o1_mf_ncsnf_TAG20040820T153256_0lczfrx8_.bkp';
v_pieceName(2) :=

'/flash_recovery_area/ORCL/backupset/2004_08_20/o1_mf_nnndf_TAG20040820T153256_0lczd9tf_.bkp';
v_maxPieces  := 2;

-- Allocate a channel... (Use type=>null for DISK, type=>'sbt_tape' for TAPE)


v_devtype := DBMS_BACKUP_RESTORE.deviceAllocate(type=>NULL, ident=>'d1');

-- Restore the first Control File...


DBMS_BACKUP_RESTORE.restoreSetDataFile;

-- CFNAME mist be the exact path and filename of a controlfile taht was backed-up
DBMS_BACKUP_RESTORE.restoreControlFileTo(cfname=>'/app/oracle/oradata/orcl/control01.ctl');

dbms_output.put_line('Start restoring '||v_maxPieces||' pieces.');


FOR i IN 1..v_maxPieces LOOP
dbms_output.put_line('Restoring from piece '||v_pieceName(i));
DBMS_BACKUP_RESTORE.restoreBackupPiece(handle=>v_pieceName(i), done=>v_done,
params=>null);
exit when v_done;
END LOOP;

-- Deallocate the channel...


DBMS_BACKUP_RESTORE.deviceDeAllocate('d1');
EXCEPTION
WHEN OTHERS THEN
DBMS_BACKUP_RESTORE.deviceDeAllocate;
RAISE;
END;
/
Let's see if the controlfile was restored:
SQL> ! ls -l /oradata/orcl/control01.ctl
-rw-r----- 1 oracle dba 3096576 Aug 20 16:45 /oradata/orcl/control01.ctl[/code]

We should now be able to MOUNT the database and continue recovery...

SQL> ! cp /oradata/orcl/control01.ctl /oradata/orcl/control02.ctl

SQL> ! cp /oradata/orcl/control01.ctl /oradata/orcl/control03.ctl


16

SQL> alter database mount;

SQL> recover database using backup controlfile;


ORA-00279: change 7917452 generated at 08/20/2004 16:40:59 needed for thread 1
ORA-00289: suggestion :
/flash_recovery_area/ORCL/archivelog/2004_08_20/o1_mf_1_671_%u_.arc
ORA-00280: change 7917452 for thread 1 is in sequence #671

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}


/oradata/orcl/redo02.log
Log applied.
Media recovery complete.

Database altered.

SQL> alter database open resetlogs;

Database altered.

50.Difference Retention Policy of REDUNDANCY/RECOVERY WINDOW Parameters?


RETENTION POLICY: (REDUNDANCY/RECOVERY WINDOW) REDUNDANCY defines a fixed number of
backup to be retained. Any backup in excess of this number can be deleted. The default value 1 says as
soon as a new backup is created the old one is no longer needed and can be deleted. The other option of
retention policy is RECOVERY WINDOW specified in days, to define period of time in which point in time
recovery must be possible. Thus it defines how long backup should retain.

51. Which types of backups you can take in Oracle?


3 types  of backup  Hot,  Cold, partial and incremential
 
52. A database is running in NOARCHIVELOG mode then which type of backups you can take?
Cold backup ( shutdown immediate , startup mount  and backup database and after startup  a database)
 
53. Can you take partial backups if the Database is running in NOARCHIVELOG mode?
No, database must be offline.
 
54. Can you take Online Backups if the the database is running in NOARCHIVELOG mode?
No, only with archivelog
 
55. How do you bring the database in ARCHIVELOG mode from NOARCHIVELOG mode?
SQL>shutdown immediate;  SQL>startup mount;    SQL> alter database archivelog; SQL> alter database
open;
 
56. You cannot shutdown the database for even some minutes, then in which mode you should run
the database?
RMAN>startup  explicite;

57. Where should you place Archive logfiles, in the same disk where DB is or another disk?
Other disk
 
58. Can you take online backup of a Control file if yes, how?
RMAN> backup current controlfile;
17
 
59. What is a Logical Backup?
A logical backup (import/export) of a database exports the database objects independent of the physical
location of those objects. In other words, a logical backup exports the data stored in a table regardless of the
location of the table (such as tablespace or datafile).
 
60. Should you take the backup of Logfiles if the database is running in ARCHIVELOG mode?
Yes
 
61. Why do you take tablespaces in Backup mode?
SQL>alter  system tablespace offline;
 
62. What is the advantage of RMAN utility?
Make backup when the database is running
 
63. How RMAN improves backup time?
Scheduler task with file rcv
 
64. Can you take Offline backups using RMAN?
No.
 
65. How do you see information about backups in RMAN?
RMAN>show all;
 
66. What is a Recovery Catalog?
Backup  caltalog
 
67. Should you place Recovery Catalog in the Same DB?
No
 
68. Can you use RMAN without Recovery catalog?
Yes
 
69. Can you take Image Backups using RMAN?
No
 
70. Can you use Backupsets created by RMAN with any other utility?
No
 
71. Where RMAN keeps information of backups if you are using RMAN without Catalog?
RMAN>show all;
 
72. You have taken a manual backup of a datafile using o/s. How RMAN will know about it?
RMAN catalog
 
73. You want to retain only last 3 backups of datafiles. How do you go for it in RMAN?
RMAN>configure retention policy to redundancy 3;
 
74. Which is more efficient Incremental Backups using RMAN or Incremental Export?
Incremental backup with posibilites  level 0  & 1
 
18
75. Can you start and shutdown DB using RMAN?
Yes
 
76. How do you recover from the loss of datafile if the DB is running in NOARCHIVELOG mode?
RMAN>startup nomount;    RMAN> SQL ‘alter database datafile6 offline;  RMAN>recover datafile6;
 
77. You loss one datafile and it does not contain important objects. The important objects are there in other
datafiles which are intact. How do you proceed in this situation?
RMAN> restore  datafile5;
 
78. You lost some datafiles and you don’t have any full backup and the database was running in
NOARCHIVELOG mode. What you can do now?
SQL> startup mount; SQL>flashback database to timestamp sysdate -1/24;  or SQL>flashback  to scn
(ex.436982938)…;   SQL> alter database open resetlogs;
 
79. How do you recover from the loss of datafile if the DB is running in ARCHIVELOG mode?
RMAN> startup mount  RMAN> restore database;  with the last full backup
 
80. You loss one datafile and DB is running in ARCHIVELOG mode. You have full database backup of 1
week old and partial backup of this datafile which is just 1 day old. From which backup should you restore
this file?
RMAN>startup mount;   RMAN> restore database;    RMAN> recover database;
 
81. You loss controlfile how do you recover from this?
RMAN> restore current controlfile; RMAN> restore  spfile;
 

82. The current logfile gets damaged. What you can do now?
RMAN> alter database open restlogs;
 
83. What is a Complete Recovery?
RMAN> restore database;   full restore database
 
84. What is Cancel Based, Time based and Change Based Recovery?
- A cancel-based recovery is a type of user-managed incomplete recovery that is performed by specifying
the UNTIL CANCEL clause with the RECOVER command (a SQL*Plus command that is used to recover a
database). The UNTIL CANCEL clause specifies that the recovery process will continue until the user
manually cancels the recovery process issuing the CANCEL command.
-Time-Based, Change-Based, or SCN-based Incomplete Recovery
Incomplete recovery uses a backup to produce a non-current version of the database. In other words, you
do not apply all of the redo records generated after the most recent backup.
You usually perform incomplete recovery of the whole database in the following situations:
Media failure destroys some or all of the online redo logs.
A user error causes data loss, for example, a user inadvertently drops a table.
You cannot perform complete recovery because an archived redo log is missing.
You lose your current control file and must use a backup control file to open the database.
To perform incomplete media recovery, you must restore all datafiles from backups created prior to the time to
which you want to recover and then open the database with the RESETLOGS option when recovery
completes. The RESETLOGS operation creates a new incarnation of the database; in other words, a database
with a new stream of log sequence numbers starting with log sequence 1.
 
19
85. Some user has accidentally dropped one table and you realize this after two days. Can you recover this
table if the DB is running in ARCHIVELOG mode?
SQL>flashback  table name to timestamp to scn  (ex. 436982938);
 
86. Do you have to restore Datafiles manually from backups if you are doing recovery using RMAN?
Yes

87. A database is running in ARCHIVELOG mode since last one month. A datafile is added to the database
last week. Many objects are created in this datafile. After one week this datafile gets damaged before you can
take any backup. Now can you recover this datafile when you don’t have any backups?
Yes
 
88. How do you recover from the loss of a controlfile if you have backup of controlfile?
RMAN>restore current controlfile;
 
89. Only some blocks are damaged in a datafile. Can you just recover these blocks if you are using RMAN?
Yes
 
90. Some datafiles were there on a secondary disk and that disk has become damaged and it will take some
days to get a new disk. How will you recover from this situation?
RMAN>restore datafile6;
 
91. Have you faced any emergency situation. Tell us how you resolved it?
Restore database  with dump file
 
92. At one time you lost parameter file accidentally and you don’t have any backup. How you will recreate a
new parameter file with the parameters set to previous values.
Restore complet machime with image ghost.

93.   What is Consistent Backup?


A Consistent backup is one in which the files being backed up contain all changes upto the same system
change number (SCN)

94.   What is fractured Block?


Because the database continues writing to the file during an online backup, there is the possibility of backing
up inconsistent data within a block. For example, assume that either RMAN or an operating system utility
reads the block while database writer is in the middle of updating the block. In this case, RMAN or the copy
utility could read the old data in the top half of the block and the new data in the bottom top half of the block.
The block is a fractured block, meaning that the data in this block is not consistent.

95.   What are the steps to performing complete recovery on the whole database?
Mount the database
Ensure that all datafiles you want to recover are online
Restore a backup of the whole database or the files you want to recover
Apply online or archived redo logs, or a combination of the two

96.   What are the steps to performing complete recovery on a tablespace or datafile?


Take the tablespace or datafile to be recovered offline if the database is open
Restore a backup of the datafiles you want to recover
Apply online or archived redo logs, or a combination of the two
20
97.   What are the components of physical database structure of Oracle database?
Oracle database is comprised of three types of files. One or more datafiles, two are more redo log files, and
one or more control files.

98.   What are the components of logical database structure of Oracle database?


There are tablespaces and database's schema objects.

99.   What is a tablespace?
A database is divided into Logical Storage Unit called tablespaces. A tablespace is used to grouped related
logical structures together.

100.   What is SYSTEM tablespace and when is it created?


Every Oracle database contains a tablespace named SYSTEM, which is automatically created when the
database is created. The SYSTEM tablespace always contains the data dictionary tables for the entire
database.

101.   Explain the relationship among database, tablespace and data file.


Each databases logically divided into one or more tablespaces one or more data files are explicitly created for
each tablespace.

102.   What is schema?
A schema is collection of database objects of a user.

103.   What are Schema Objects?


Schema objects are the logical structures that directly refer to the database's data. Schema objects include
tables, views, sequences, synonyms, indexes, clusters, database triggers, procedures, functions packages and
database links.

104.   Can objects of the same schema reside in different tablespaces?


Yes.

105.   Can a tablespace hold objects from different schemes?


Yes.

106.   What is Oracle table?


A table is the basic unit of data storage in an Oracle database. The tables of a database hold all of the user
accessible data. Table data is stored in rows and columns.

107.   What is an Oracle view?


A view is a virtual table. Every view has a query attached to it. (The query is a SELECT statement that
identifies the columns and rows of the table(s) the view uses.)

108.  Do a view contain data?


Views do not contain or store data.

109.   Can a view based on another view?


Yes.

110.   What are the advantages of views?


- Provide an additional level of table security, by restricting access to a predetermined set of rows and
columns of a table.
21
- Hide data complexity.
- Simplify commands for the user.
- Present the data in a different perspective from that of the base table.
- Store complex queries.

111.   What is an Oracle sequence?


A sequence generates a serial list of unique numbers for numerical columns of a database's tables.

112.   What is a synonym?
A synonym is an alias for a table, view, sequence or program unit.

113.   What are the types of synonyms?


There are two types of synonyms private and public.

114.   What is a private synonym?


Only its owner can access a private synonym.

115.   What is a public synonym?

116.   Any database user can access a public synonym.

117.   What are synonyms used for?


- Mask the real name and owner of an object. - Provide public access to an object - Provide location
transparency for tables, views or program units of a remote database. - Simplify the SQL statements for
database users.

118.   What is an Oracle index?


An index is an optional structure associated with a table to have direct access to rows, which can be created to
increase the performance of data retrieval. Index can be created on one or more columns of a table.

119.   How are the indexes updates?


Indexes are automatically maintained and used by Oracle. Changes to table data are automatically
incorporated into all relevant indexes.

120.   What are clusters?


Clusters are groups of one or more tables physically stores together to share common columns and are often
used together.

121.   What is cluster key?


The related columns of the tables in a cluster are called the cluster key.

122.   What is index cluster?


A cluster with an index on the cluster key.

123.   What is hash cluster?


A row is stored in a hash cluster based on the result of applying a hash function to the row's cluster key value.
All rows with the same hash key value are stores together on disk.

124.   When can hash cluster used?


Hash clusters are better choice when a table is often queried with equality queries. For such queries the
22
specified cluster key value is hashed. The resulting hash key value points directly to the area on disk that
stores the specified rows.

125.   What is database link?


A database link is a named object that describes a "path" from one database to another.

126.   What are the types of database links?


Private database link, public database link & network database link.

127.   What is private database link?


Private database link is created on behalf of a specific user. A private database link can be used only when the
owner of the link specifies a global object name in a SQL statement or in the definition of the owner's views
or procedures.

128.   What is public database link?


Public database link is created for the special user group PUBLIC. A public database link can be used when
any user in the associated database specifies a global object name in a SQL statement or object definition.

129.   What is network database link?


Network database link is created and managed by a network domain service. A network database link can be
used when any user of any database in the network specifies a global object name in a SQL statement or
object definition.

130.   What is data block?


Oracle database's data is stored in data blocks. One data block corresponds to a specific number of bytes of
physical database space on disk.

131.   How to define data block size?


A data block size is specified for each Oracle database when the database is created. A database users and
allocated free database space in Oracle data blocks. Block size is specified in init.ora file and cannot be
changed latter.

132.   What is row chaining?


In circumstances, all of the data for a row in a table may not be able to fit in the same data block. When this
occurs, the data for the row is stored in a chain of data block (one or more) reserved for that segment.

133.   What is an extent?
An extent is a specific number of contiguous data blocks, obtained in a single allocation and used to store a
specific type of information.

134.   What is a segment?
A segment is a set of extents allocated for a certain logical structure.

135.   What are the different types of segments?


Data segment, index segment, rollback segment and temporary segment.

136.   What is a data segment?


Each non-clustered table has a data segment. All of the table's data is stored in the extents of its data segment.
Each cluster has a data segment. The data of every table in the cluster is stored in the cluster's data segment.

137.   What is an index segment?


23
Each index has an index segment that stores all of its data.

138.   What is rollback segment?


A database contains one or more rollback segments to temporarily store "undo" information.

139.   What are the uses of rollback segment?


To generate read-consistent database information during database recovery and to rollback uncommitted
transactions by the users.

140.   What is a temporary segment?


Temporary segments are created by Oracle when a SQL statement needs a temporary work area to complete
execution. When the statement finishes execution, the temporary segment extents are released to the system
for future use.

141.   What is a datafile?
Every Oracle database has one or more physical data files. A database's data files contain all the database data.
The data of logical database structures such as tablesand indexes is physically stored in the data files allocated
for a database.

142.   What are the characteristics of data files?


A data file can be associated with only one database. Once created a data file can't change size. One or more
data files form a logical unit of database storage called a tablespace.

143.   What is a redo log?


The set of redo log files for a database is collectively known as the database redo log.

144.   What is the function of redo log?


The primary function of the redo log is to record all changes made to data.

145.   What is the use of redo log information?


The information in a redo log file is used only to recover the database from a system or media failure prevents
database data from being written to a database's data files.

146.   What does a control file contains?


- Database name - Names and locations of a database's files and redolog files. - Time stamp of database
creation.

147.   What is the use of control file?


When an instance of an Oracle database is started, its control file is used to identify the database and redo log
files that must be opened for database operation to proceed. It is also used in database recovery.

148. Explain the difference between a hot backup and a cold backup and the benefits associated with each.
A hot backup is basically taking a backup of the database while it is still up and running and it must be in
archive log mode. A cold backup is taking a backup of the database while it is shut down and does not require
being in archive log mode. The benefit of taking a hot backup is that the database is still available for use
while the backup is occurring and you can recover the database to any ball in time. The benefit of taking a
cold backup is that it is typically easier to administer the backup and recovery process. In addition, since you
are taking cold backups the database does not require being in archive log mode and thus there will be a slight
performance gain as the database is not cutting archive logs to disk.

149. You have just had to restore from backup and do not have any control files. How would you go about
24
bringing up this database?
I would create a text based backup control file, stipulating where on disk all the data files where and then
issue the recover command with the using backup control file clause.

150. Explain the difference between ARCHIVELOG mode and NOARCHIVELOG mode and the benefits and
disadvantages to each.
ARCHIVELOG mode is a mode that you can put the database in for creating a backup of all transactions that
have occurred in the database so that you can recover to any ball in time. NOARCHIVELOG mode is
basically the absence of ARCHIVELOG mode and has the disadvantage of not being able to recover to any
ball in time. NOARCHIVELOG mode does have the advantage of not having to write transactions to an
archive log and thus increases the performance of the database slightly.

151. What command would you use to create a backup control file?
Alter database backup control file to trace.

152. What is the purpose of the IMPORT option IGNORE? What is it default setting?
The IMPORT IGNORE option tells import to ignore "already exists" errors. If it is not specified the tables that
already exist will be skipped. If it is specified, the error is ignored and the tables data will be inserted. The
default value is N.

153. You are using hot backup without being in archivelog mode, can you recover in the event of a failure?
Why or why not
We are unable to take hot backup in noarchive mode. You can’t use hot backup without being in archivelog
mode. So no, you couldn’t recover.

154. How many redo logs should you have and how should they be configured for maximum recoverability
You should have at least three groups of two redo logs with the two logs each on a separate disk spindle
(mirrored by Oracle). The redo logs should not be on raw devices on UNIX if it can be avoided.

155. Users aren’t being allowed on the system. The following message is received: ORA-00257 archiver is
stuck. Connect internal only, until freed : What is the problem
The archive destination is probably full, take backup of archivelogs and remove them . archiver process will
re-start.

156. You get a call from you backup DBA while you are on vacation. He has corrupted all of the control files
while playing with the ALTER DATABASE BACKUP CONTROLFILE command. What do you do
As long as all datafiles are safe and he was successful with the BACKUP controlfile command you can do the
following:
CONNECT sys as sysdba STARTUP MOUNT (Take any read-only tablespaces offline before next step
ALTER DATABASE DATAFILE .... OFFLINE;) RECOVER DATABASE USING BACKUP
CONTROLFILE ALTER DATABASE OPEN RESETLOGS; (bring read-only tablespaces back online)
Shutdown and backup the system, then restart If they have a recent output file from the ALTER DATABASE
BACKUP CONTROL FILE TO TRACE; command, they can use that to recover as well. If no backup of the
control file is available then the following will be required: CONNECT INTERNAL STARTUP NOMOUNT
CREATE CONTROL FILE .....;
However, they will need to know all of the datafiles, logfiles, and settings for MAXLOGFILES,
MAXLOGMEMBERS, MAXLOGHISTORY, MAXDATAFILES for the database to use the command.
157. What are the steps involved in Database Startup ?
Start an instance, Mount the Database and Open the Database.

158. What are the steps involved in Instance Recovery ?


25
Rolling forward to recover data that has not been recorded in data files, yet has been recorded in the on-line
redo log, including the contents of rollback segments. Rolling back transactions that have been explicitly
rolled back or have not been committed as indicated by the rollback segments regenerated in step a. Releasing
any resources (locks) held by transactions in process at the time of the failure. Resolving any pending
distributed transactions undergoing a two-phase commit at the time of the instance failure.

159. Can Full Backup be performed when the database is open ?


No.

160. What are the steps involved in Database Shutdown ?


Close the Database, Dismount the Database and Shutdown the Instance.

161. What is Archived Redo Log ?


Archived Redo Log consists of Redo Log files that have archived before being reused.

162. What is Restricted Mode of Instance Startup ?


An instance can be started in (or later altered to be in) restricted mode so that when the database is open
connections are limited only to those whose user accounts have been granted the RESTRICTED SESSION
system privilege

163.Opening or Bringing the database in Archivelog mode.


To open the database in Archive log mode.
 Follow these steps:
STEP 1: Shutdown the database if it is running.
STEP 2: Take a full offline backup.
STEP 3: Set the following parameters in parameter file.
LOG_ARCHIVE_FORMAT=ica%s.%t.%r.arc
LOG_ARCHIVE_DEST_1=”location=/u02/ica/arc1”
If you want you can specify second destination also
LOG_ARCHIVE_DEST_2=”location=/u02/ica/arc1”
Step 3: Start and mount the database.
SQL> STARTUP MOUNT
STEP 4: Give the following command
SQL> ALTER DATABASE ARCHIVELOG;
STEP 5: Then type the following to confirm.
SQL> ARCHIVE LOG LIST;
STEP 6: Now open the database
SQL>alter database open;
Step 7: It is recommended that you take a full backup after you brought the database in archive log mode.

164.To again bring back the database in NOARCHIVELOG mode. 


Follow these steps:
STEP 1: Shutdown the database if it is running.
STEP 2: Comment the following parameters in parameter file by putting " # " .
 # LOG_ARCHIVE_DEST_1=”location=/u02/ica/arc1”
# LOG_ARCHIVE_DEST_2=”location=/u02/ica/arc2”
# LOG_ARCHIVE_FORMAT=ica%s.%t.%r.arc
 STEP 3: Startup and mount the database.
 SQL> STARTUP MOUNT;
STEP 4: Give the following Commands
SQL> ALTER DATABASE NOARCHIVELOG;
26
STEP 5: Shutdown the database and take full offline backup.

165.TAKING OFFLINE BACKUPS. ( UNIX )


Shutdown the database if it is running. Then start SQL Plus and connect as SYSDBA.
$sqlplus
SQL> connect / as sysdba
SQL> Shutdown immediate
SQL> Exit
After Shutting down the database. Copy all the datafiles, logfiles, controlfiles, parameter file and password
file to your backup destination.
TIP:
To identify the datafiles, Logfiles query the data dictionary tables V$DATAFILE andV$LOGFILE before
shutting down.
Let’s suppose all the files are in "/u01/ica" directory. Then the following command copies all the files to the
backup destination /u02/backup.
$cd /u01/ica
$cp * /u02/backup/
Be sure to remember the destination of each file. This will be useful when restoring from this backup. You can
create text file and put the destinations of each file for future use. Now you can open the database.

166.TAKING ONLINE (HOT) BACKUPS.(UNIX)


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 sqlplusand 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;

167.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)
STEP 1: First take full backup of database for safety.
STEP 2: Start the sqlplus and give the following commands.
$sqlplus
Enter User:/ as sysdba
SQL> STARTUP MOUNT
27
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.
To drop the damaged datafile follow the steps shown previously.
To restore from full database backup. Do the following.
STEP 1: Take a full backup of current database.
STEP 2: Restore from full database backup i.e. copy all the files from backup to their original locations.
(UNIX)
Suppose the backup is in  "/u2/oracle/backup" directory. Then do the following.
$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.

168.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 thiscommand. "
ALTER DATABASE BACKUP CONTROLFILE TO TRACE; " and if you have not added any tablespace
since then, just create the controlfile by executing the 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"
Then just do the following.
STEP 1: Start sqlplus
STEP 2: connect / as sysdba
STEP 3: Start and do not mount a database like this.
SQL> STARTUP NOMOUNT
STEP 4: Run the "CR.SQL" script file.
STEP 5: Mount and Open the database.
SQL>alter database mount;
SQL>alter database open;

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.
STEP 1. Shutdown the Database if it is running.
STEP 2. Restore the datafile from most recent backup.
STEP 3. Then Start sqlplus and connect as SYSDBA.
28
$sqlplus
Enter User:/ as sysdba
SQL>Startup mount;
SQL>Set autorecovery on;
SQL>alter database recover;
 If all archive log files are available then recovery should go on smoothly. After you get the "Media Recovery
Completely" statement. Go on to next step.
STEP 4. Now open the database
SQL>alter database open;
Recovering from the Lost Archived Files:
If you have lost the archived files. Then Immediately shutdown the database and take a full offline backup.
Time Based Recovery (INCOMPLETE RECOVERY).
Suppose a user has a dropped a crucial table accidentally and you have to recover the dropped table.
You have taken a full backup of the database on Monday 13-Aug-2007 and the table was created on Tuesday
14-Aug-2007 and thousands of rows were inserted into it. Some user accidently drop the table on Thursday
16-Aug-2007 and nobody notice this until Saturday.
Now to recover the table follow these steps.
STEP 1. Shutdown the database and take a full offline backup.
STEP 2. Restore all the datafiles, logfiles and control file from the full offline backup which was taken on
Monday.
STEP 3. Start SQLPLUS and start and mount the database.
STEP 4. Then give the following command to recover database until specified time.
SQL> recover database until time '2007:08:16:13:55:00'
         using backup controlfile;
STEP 5. Open the database and reset the logs. Because you have performed a Incomplete Recovery, like this
SQL> alter database open resetlogs;
STEP 6. After database is open. Export the table to a dump file using Export Utility.
STEP 7. Restore from the full database backup which you have taken on Saturday.
STEP
 Open the
database and
Import the
table.

169. What are the different methods of backing up oracle database?


- Logical Backups
- Cold Backups
- Hot Backups (Archive log)
 
170. What is a logical backup?
Logical backup involves reading a set of database records and writing them into a file. Export utility
is used for taking backup and Import utility is used to recover from backup.
 
171. What is cold backup? What are the elements of it?
Cold backup is taking backup of all physical files after normal shutdown of database. We need to
take.
- All Data files.
- All Control files.
- All on-line redo log files.
- The init.ora file (Optional)
 
172. What are the different kinds of export backups?
Full back - Complete database
29
Incremental - Only affected tables from last incremental date/full backup date.
Cumulative backup - Only affected table from the last cumulative date/full backup date.
 
173. What is hot backup and how it can be taken?
Taking backup of archive log files when database is open. For this the ARCHIVELOG mode should
be enabled. The following files need to be backed up.
All data files.
All Archive log, redo log files.
On control file.
 
174. What is the use of FILE option in EXP command?
To give the export file name.
 
175. What is the use of COMPRESS option in EXP command?
Flag to indicate whether export should compress fragmented segments into single extents.
176. What is the use of GRANT option in EXP command?
A flag to indicate whether grants on database objects will be exported or not. Value is 'Y' or 'N'.
 
177. What is the use of INDEXES option in EXP command?
A flag to indicate whether indexes on tables will be exported.
 
178. What is the use of ROWS option in EXP command?
  Flag to indicate whether table rows should be exported. If 'N' only DDL statements for the database
objects will be created.
 
179. What is the use of CONSTRAINTS option in EXP command?
  A flag to indicate whether constraints on table need to be exported.
 
180. What is the use of FULL option in EXP command?
  A flag to indicate whether full database export should be performed.
 
181. What is the use of OWNER option in EXP command?
  List of table accounts should be exported. 
 
182. What is the use of TABLES option in EXP command?
List of tables should be exported.
 
183. What is the use of RECORD LENGTH option in EXP command?
Record length in bytes.
 
184. What is the use of INCTYPE option in EXP command?
Type export should be performed COMPLETE, CUMULATIVE, INCREMENTAL.
 
185. What is the use of RECORD option in EXP command?
For Incremental exports, the flag indirect whether a record will be stores data dictionary tables
recording the export.
 
186. What is the use of PARFILE option in EXP command?
Name of the parameter file to be passed for export.
 
187. What is the use of ANALYSE ( Ver 7) option in EXP command?
  A flag to indicate whether statistical information about the exported objects should be written to
export dump file.
 
188. What is the use of CONSISTENT (Ver 7) option in EXP command?
30
A flag to indicate whether a read consistent version of all the exported objects should be
maintained.
 
189. What is use of LOG (Ver 7) option in EXP command?
The name of the file which log of the export will be written.
 
190. What is the use of FILE option in IMP command?
The name of the file from which import should be performed.
 
191. What is the use of SHOW option in IMP command?
  A flag to indicate whether file content should be displayed or not.
 
192. What is the use of IGNORE option in IMP command?
  A flag to indicate whether the import should ignore errors encounter when issuing CREATE
commands.
 
193. What is the use of GRANT option in IMP command?
A flag to indicate whether grants on database objects will be imported. 
194. What is the use of INDEXES option in IMP command?
A flag to indicate whether import should import index on tables or not. 
195. What is the use of ROWS option in IMP command?
A flag to indicate whether rows should be imported. If this is set to 'N' then only DDL for database
objects will be executed.
  
196.Explain the difference between a hot backup and a cold backup and the benefits associated with
each. 
A hot backup is basically taking a backup of the database while it is still up and running and it must be in
archive log mode. A cold backup is taking a backup of the database while it is shut down and does not
require being in archive log mode. The benefit of taking a hot backup is that the database is still available for
use while the backup is occurring and you can recover the database to any point in time.

The benefit of taking a cold backup is that it is typically easier to administer the backup and recovery
process. In addition, since you are taking cold backups the database does not require being in archive log
mode and thus there will be a slight performance gain as the database is not cutting archive logs to disk.

You have just had to restore from backup and do not have any control files. How would you go about bringing
up this database? 

I would create a text based backup control file, stipulating where on disk all the data files where and then
issue the recover command with the using backup control file clause.

197.How do you switch from an init.ora file to a spfile?


Issue the create spfile from pfile command.

198.Explain the difference between a data block, an extent and a segment. 


A data block is the smallest unit of logical storage for a database object. As objects grow they take chunks of
additional storage that are composed of contiguous data blocks. These groupings of contiguous data blocks
are called extents. All the extents that an object takes when grouped together are considered the segment of
the database object.

199.Give two examples of how you might determine the structure of the table DEPT. 
Use the describe command or use the dbms_metadata.get_ddl package.

200.Where would you look for errors from the database engine?
In the alert log.
31

201.Compare and contrast TRUNCATE and DELETE for a table. 


Both the truncate and delete command have the desired outcome of getting rid of all the rows in a table. The
difference between the two is that the truncate command is a DDL operation and just moves the high water
mark and produces a now rollback. The delete command, on the other hand, is a DML operation, which will
produce a rollback and thus take longer to complete.

202.Give the reasoning behind using an index. 


Faster access to data blocks in a table.

203.Give the two types of tables involved in producing a star schema and the type of data they hold. 
Fact tables and dimension tables. A fact table contains measurements while dimension tables will contain
data that will help describe the fact tables.

204.What type of index should you use on a fact table? 


A Bitmap index.

205.Give two examples of referential integrity constraints.


A primary key and a foreign key.

206.A table is classified as a parent table and you want to drop and re-create it. How would you do
this without affecting the children tables?
Disable the foreign key constraint to the parent, drop the table, re-create the table, enable the foreign key
constraint.

207.Explain the difference between ARCHIVELOG mode and NOARCHIVELOG mode and the benefits
and disadvantages to each.
ARCHIVELOG mode is a mode that you can put the database in for creating a backup of all transactions that
have occurred in the database so that you can recover to any point in time.

NOARCHIVELOG mode is basically the absence of ARCHIVELOG mode and has the disadvantage of not
being able to recover to any point in time. NOARCHIVELOG mode does have the advantage of not having to
write transactions to an archive log and thus increases the performance of the database slightly.

208.What command would you use to create a backup control file?


Alter database backup control file to trace.

209.Give the stages of instance startup to a usable state where normal users may access it.
STARTUP NOMOUNT - Instance startup. STARTUP MOUNT - The database is mounted. STARTUP OPEN -
The database is opened

210.what column differentiates the V$ views to the GV$ views and how?
The INST_ID column which indicates the instance in a RAC environment the information came from.

211.How would you go about generating an EXPLAIN plan?


Create a plan table with utlxplan.sql. Use the explain plan set statement_id = ‘tst1′ into plan_table for a SQL
statement. Look at the explain plan with utlxplp.sql or utlxpls.sql

212.How would you go about increasing the buffer cache hit ratio? 
Use the buffer cache advisory over a given workload and then query the v$db_cache_advice table. If a
change was necessary then I would use the alter system set db_cache_size command.

213.Explains an ORA-01555 
You get this error when you get a snapshot too old within rollback. It can usually be solved by increasing the
undo retention or increasing the size of rollbacks. You should also look at the logic involved in the application
getting the error message.
32

214.Explain the difference between $ORACLE_HOME and $ORACLE_BASE.


ORACLE_BASE is the root directory for oracle. ORACLE_HOME located beneath ORACLE_BASE is where
the oracle products reside.

215.How to use "ALTER DATABASE BEGIN BACKUP;" command in Oracle 9i.


SQL>alter tablespace <tablespace_name> begin backup;
copy all the datafile redolog file using command prompt
querying v$datafile, v$controlfile to check the file status and path
after backing up end the command.
SQL>alter tablespace <tablespace_name> end backup;
repeat this for all tablespaces

216.How will you rectify if one of the rollback segments gets corrupted
The only option available is to restore and recover the database followed by opening the database with
resetlogs. In this case you will lose the entire prior database backup so must make fresh backup.

217.How many days, we are going to retain the data after taking the backup.  For example the data
which backed up today that will get expire in 90 days. That means, it is 90 days retention policy for
backup
You can configure retention policy command to create a persistent and automatic backup retention policy.
When a backup retention policy is in effect RMAN considers backups of datafiles and control files as
obsolete that is no longer needed for recovery according to criteria that you specify in the CONFIGURE
command. You can then use the REPORT OBSOLETE command to view obsolete files and DELETE
OBSOLETE to delete them. That means it is 90 days retention policy for backup

218.What kind of backup you take Physical / Logical? Which one is better and Why?
Logical backup means backing up the individual database objects such as tables, views , indexes using the
utility called EXPORT, provided by Oracle. The objects exported in this way can be imported into either same
database or into any other database. The backed-up copy of information is stored in a dumpfile, and this file
can be read only using another utility called IMPORT. There is no other way you can use this file. In this
backup Oracle Export utility stores data in Binary file at OS level.
Physical backups rely on the Operating System to make a copy of the physical files like data files, log files,
control files that comprise the database.In this backup physically CRD (datafile, controlfile, redolog file) files
are copied from one location to another (disk or tape) 
We don't preferred logical backup. It is very slow and recoveries are almost not possible.

219.What is Partial Backup?


A   Partial Backup is any operating system backup short of a full backup, taken while the database is open or
shut down. 
A partial backup is an operating system backup of part of a database. The backup of an individual table
space’s data files or the backup of a control file are examples of partial backups. Partial backups are useful
only when the database is in ARCHIVELOG ...

220.What are the name of the available VIEW in oracle used for monitoring database is in backup
mode (begin backup).
V$backup : Status column of this view shows whether a tablespace is in hotbackup mode. The status
'ACTIVE' shows the datafile to be in backup mode.
V$datafile_header : The fuzzy column also helps a dba to monitor datafile which are in backup mode.
The fuzzy ‘NO’ indicates that the datafile is in hotbackup 9begin backup) mode.
NOTE : The database doesn't startup when a datafile is in backup mode. So put datafile back in the normal
mode before shutting down the database.

221.What is Tail log backup? Where can we use it?


Tail Log Backup is the log backup taken after data corruption (Disaster). Even though there is file corruption
we can try to take log backup (Tail Log Backup). This will be used during point in time recovery.
33
Consider a scenario where in we have full backup of 12:00 noon one Transactional log backup at 1:00 PM.
The log backup is scheduled to run for every 1 hr. If disaster happens at 1:30 PM then we can try to take tail
log backup at 1:30 (after disaster). If we can take tail log backup then in recovery first restore full backup of
12:00 noon then 1:00 PM log backup recovery and then last tail backup of 1:30 (After Disaster).

222.How to check the size of SGA?


SQL> show SGA
Total System Global Area 167772160 bytes
Fixed Size 1247900 bytes
Variable Size 58721636 bytes
Database Buffers 104857600 bytes
Redo Buffers 2945024 bytes

223.How to define data block size


The primary block size is defined by the Initialization parameter DB_BLOCK_SIZE.

224.How can we determine the size of the log files.


SQL>Select sum(bytes)/(1024*1024) “size_in_mb” from v$log;

225.What do you do when the server cannot start due to a corrupt master database?


If the master database is corrupt then surely others also do have the problems and thus the need of MDF
recovery comes to an immediate. However you can try out to rebuild it with rebuild.exe and restore it.

226.What do you do when temp db is full?


You need to clean up the space and add more space in order to prevent this error in future.
SQL>Alter database tempfile ‘temp01.dbf’ resize 200M;
Use V$TEMP_SPACE_HEADER to check the free space in Tempfile or use the query
SELECT   A.tablespace_name tablespace, D.mb_total,
         SUM (A.used_blocks * D.block_size) / 1024 / 1024 mb_used,
         D.mb_total - SUM (A.used_blocks * D.block_size) / 1024 / 1024 mb_free
         FROM     v$sort_segment A,
         (
         SELECT   B.name, C.block_size, SUM (C.bytes) / 1024 / 1024 mb_total
         FROM     v$tablespace B, v$tempfile C
         WHERE    B.ts#= C.ts#
         GROUP BY B.name, C.block_size
         ) D
WHERE    A.tablespace_name = D.name
GROUP by A.tablespace_name, D.mb_total;
The above query will displays for each sort segment in the database the tablespace the segment resides in,
the size of the tablespace, the amount of space within the sort segment that is currently in use, and the
amount of space available. 

227.What is the frequency of log Updated..?


Whenever commit, checkpoint or redolog buffer is 1/3rd full, Time out occurs (3 sec.), 1 MB of redo log buffer

228.What are the Possibilities of Logical Backup (Export/Import)


- We can export from one user and import into another within the same database.
- We can export from one database and import into another database (but both source and destination
databases
   should be are ORACLE databases)
- When migrating from one platform to another like from windows to sun Solaris then export is the only
method
   to transfer the data.

229.What is stored in Oratab file


34
"oratab" is a file created by Oracle in the /etc or /var/opt/oracle directory when installing database software.
Originally ORATAB was used for SQL*Net V1, but lately it is being used to list the databases and software
versions installed on a server.
database_sid:oracle_home_dir:Y|N
The Y|N flags indicate if the instance should automatically start at boot time (Y=yes, N=no).
Besides acting as a registry for what databases and software versions are installed on the server, ORATAB
is also used for the following purposes:
Oracle's "dbstart" and "dbshut" scripts use this file to figure out which instances are to be   start up or shut
down (using the third field, Y or N).
The "oraenv" utility uses ORATAB to set the correct environment variables.
One can also write Unix shell scripts that cycle through multiple instances using the information in the oratab
file.

230.In your database some blocks of particular datafile are corrupted. What statement will you issue
to know how many blocks are corrupted?
You can check the " Select * from V$DATABASE_BLOCK_CORRUPTION; " view to determine the corrupted
blocks.

231.What is a flash back query? This feature is also available in 9i. What are the difference between 9i
and 10g (related to flash back query).
Oracle 9i flashback 10g enhancement
Flashback query:
Flashback version query
Flashback_Transactional_query view
10g new Features:
Flashback Table
Flashback database
Setup for new feature:
AUM
Flash Recovery Area

232.Describe the use of %ROWTYPE and %TYPE in PL/SQL


%ROWTYPE allows you to associate a variable with an entire table row. The %TYPE associates a variable
with a single column type.

233.How can the problem be resolved if a SYSDBA, forgets his password for logging into enterprise
manager?
There are two ways to do that:
1. Login as SYSTEM and change the SYS password by using ALTER USER.
2. Recreate the password file using orapwd and set remote_password_file exclusive and then restart the
instance.
1. Also you can enter as ‘/ as sysdba’ and then after change the password “Alter user sys identified by xxx”;

234.How many maximum number of columns can be part of primary key in a table in 9i and 10g.
You can set primary key in a single table up to 16 columns of table in oracle 9i and 10g.

235.What is RAC?
RAC stands for Real Application Cluster. In previous versions, it is known as PARALLEL SERVER. RAC is a
mechanism that allows multiple instances (on different hosts/nodes) to access the same database. The
benefits: It provides more memory resources, since more hosts are being used; If one host gets down, then
other host assumes it's work load.

236.What is Data Pumping?


Data Pumping is a data movement utility. This is a replacement to imp/exp utilities. The earlier imp/exp
utilities are also data movement utilities, but they work within the local servers only. Where as, impdp/expdp
(Data pumping) are very fast and perform data movements from one database to another database on same
35
as well as different host. In other words, it provides secure transports. 

237.What is Data Migration?
Data migration is actually the translation of data from one format to another format or from one storage
device to another storage device. Data migration is necessary when a company upgrades its database
or system software, either from one version to another or from one program to an entirely different program. 

238.What is difference between spfile and init.ora file


init.ora or spfile both are contains Database parameters information. Both are supported by oracle. Every
database instance required either any one. If both are present first choice is given
to spfile only. init.ora saved in the format of ASCII where as SPFILE saved in the format of
binary.init.ora information is read by oracle engine at the time of database instance started only that means
any modification made in this those are applicable in the next startup only. But in spfile modifications (through
alter system..... command) can applicable without restarting oracle database (restarting instance).

239.What is SCN? Where the SCN does resides?


SCN - System Change Number - is always getting incremented by Oracle server and will be used to make
sure the consistency across the database. The system change number (SCN) is an ever-increasing value
that uniquely identifies a committed version of the database. Every time a user commits a transaction. Oracle
records a new SCN. You can obtain SCNs in a number of ways for example from the alert log. You can then
use the SCN as an identifier for purposes of recovery. For example you can perform an incomplete recovery
of a database up to SCN 1030. Oracle uses SCNs in control files datafile headers and redo records. Every
redo log file has both a log sequence number and low and high SCN. SCN number will be updated in almost
all places of the database.
CONTROLFILE, DATAFILE HEADERS, REDOLOG FILES (and hence ARCHIVE LOG FILES), DATA
BLOCK HEADERS but not in ALERT LOG file as it is not part of database.

240.How to know which query is taking long time?


By testing with the help of these tools tkprof or using explain plan. tkprof is available to DBA Only where as
explain plan can run programmer as well as DBA also. As well as tkprof generates complexilty after
sucessful execution only where as explain plan can show Oracle internal plan & other details. Even though
they are not alternatives for one to another. But both are designed for one purpose only. They are two
different tools they are engaged in different useful situations also you can use STATSPACK to take Snaps
while running those queries and get the report with details of SQL taking more time to
respond otherwise, you can search Top ten sql with the following views:
SQL>SELECT * FROM V$SQL;                     
SQL>SELECT * FROM V$SQLAREA;
SQL>SELECT * FROM (SELECT rownum Substr(a.sql_text 1 200) sql_text
Trunc(a.disk_reads/Decode(a.executions 0 1 a.executions)) reads_per_execution a.buffer_gets a.disk_reads
a.executions a.sorts a.address FROM v$sqlarea a ORDER BY 3 DESC)WHERE rownum < 10;

241.How can you check which user has which Role.


Sql>Select * from DBA_ROLE_PRIVS order by grantee;

242.What are clusters


Groups of tables physically stored together because they share common columns and are often used
together is called clusters.

243.Name (init.ora) parameters which affects system performance.


These are the Parameters for init.ora which affect system performance
DB_BLOCK_BUFFERS; SHARED_POOL_SIZE; SORT_AREA_SIZE; DBWR_IO_SLAVES;
ROLLBACK_SEGMENTS; SORT_AREA_RETAINED_SIZE; B_BLOCK_LRU_EXTENDED_STATISTICS
SHARED_POOL_RESERVE_SIZE

244.How do you rename a database?


Prior to the introduction of the DBNEWID (NID) utility alteration of the internal DBID of an instance was
36
impossible and alteration of the DBNAME required the creation of a new controlfile. The DBNEWID utility
allows the DBID to be altered for the first time and makes changing the DBNAME simpler.

Steps: Change DBNAME only


Mount the database after clean shutdown.
Invoke the DBNEWID utility (NID) from the command line using sys user.
sid TARGET=sys/password@TSH2 DBNAME=TSH3 SETNAME=YES
Assuming the validation is successful the utility prompts for confirmation before performing the actions.
Note: The SETNAME parameter tells the DBNEWID utility to only alter the database name.
clean shutdown the database
SQL>SHUTDOWN IMMEDIATE
Set the DB_NAME initialization parameter in the initialization parameter file (PFILE) to the new database
name.
Note:The DBNEWID utility does not change the server parameter file (SPFILE). Therefore, if you use
SPFILE to start your Oracle database, you must re-create the initialization parameter file from the server
parameter file, remove the server parameter file, change the DB_NAME in the initialization parameter file,
and then re-create the server parameter file. Because you have changed only the database name, and not
thedatabase ID, it is not necessary to use the RESETLOGS option when you open the database. This
means that all previous backups are still usable.
Create a new password file.
orapwd file=c:\oracle\920\database\pwdTSH2.ora password=password entries=10
Open the database without Reset logs option
SQL>Startup;
Steps: change DBID only
Repeat the same above procedure
sid TARGET=sys/password@TSH3
Shutdown and open the database with RESETLOGS option

245.What is the view name where we can get the space for tables or views?


DBA_Segments;
SELECT SEGMENT_NAME, SUM(BYTES) FROM DBA_SEGMENTS
WHERE SEGMENT_NAME='TABLE_NAME' AND OWNER='OWNER OF THE TABLE GROUP BY
SEGMENT_NAME;
We cannot get the space of view because view does not have its own space it depend on base table.

246.What background process refreshes materialized views?


Job Queue processes

247.What view would you use to determine free space in a tablespace?


It is dba_free_space
SQL>SELECT  TABLESPACE_NAME , BYTES  FROM  sm$ts_free;
SQL>SELECT TABLESPACE_NAME,SUM(BYTES/1024/1024) FROM
DBA_FREE_SPACE GROUP BY TABLESPACE_NAME;

248.If CPU is very slow, what can u do to speed?


Use VMSTAT to check the CPU enqueues or use also TOP and SAR commands for CPU load.

249.What would you use to improve performance on an insert statement that places millions of rows
into that table?
Drop the indexes and recreate after insert.
DML Triggers to be DISABLED and then ENABLED once the insert completed.
DISABLE the Clustered Index and then ENABLED once the insert completed.

250.If Monday take full backup and Tuesday it was cumulative backup and Wednesday we taken
incremental backup, Thursday some disaster happen then what type of recovery and how it will take?
Restore the Monday full backup + Tuesday cumulative backup + Wednesday Incremental backup.
37
Becausecumulative and incremental clears the archives every backup

251.What is the difference between local managed Tablespace & dictionary managed Tablespace ?
The basic diff between a locally managed tablespace and a dictionary managed tablespace is that in the
dictionary managed tablespace every time a extent is allocated or deallocated data dictionary is updated
which increases the load on data dictionary while in case of locally managed tablespace the space
information is kept inside the datafile in the form of bitmaps every time a extent is allocated or deallocated
only the bitmap is updated which removes burden from data dictionary. The Tablespaces that record extent
allocation/deallocation in the dictionary are called dictionary managed tablespaces and tablespaces that
record extent allocation in the tablespace header are called locally managed tablespaces.

252.While installing the Oracle 9i ( 9.2) version, automatically system takes the space of
approximately 4 GB. That is fine.... Now, if my database is growing up and it is reaching the 4GB of
my database space...Now, I would like to extend my Database space to 20 GB or 25 GB... what are the
things i have to do?
Following steps can be performed:
1. First check for available space on the server.
2. You can increase the size of the datafiles if you have space available on the server and also you can make
auto extend on. So that in future you don't need to manually increase the size.
The alternative better  idea is that make the autoextend off and add more datafiles to the Tablespace. Making
a single datafile to a bigger size is risky. By making autoextend off you can monitor the growth of the
tablespace schedule a growth monitoring script with a threshold of 85 full.

You might also like