0% found this document useful (0 votes)
38 views

Interview Questions

oracle interview questions from kanna techonologies

Uploaded by

Kamalakshi Raj
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views

Interview Questions

oracle interview questions from kanna techonologies

Uploaded by

Kamalakshi Raj
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 18

1) What is snapshot control file in RMAN ?

SNAPSHOT CONTROLFILE
A snapshot control file is created by RMAN during the backup process that serves as
a point-in-time copy of the database control file. This will ensure that that backups
being taken is consistent to a given point in time. For example, if you add a datafile or
tablespace to a database after the backup has started, (assuming an online backup and
before the backup has ended), that datafile and/or tablespace will not be included in
the backup. It is sometimes required that the location and name of the snapshot
control file be changed from its default.
To set the snapshot control file to a different location (and name) use the following:
RMAN> CONFIGURE SNAPSHOT CONTROLFILE NAME TO
'/orabackup/rman/ORA920/scontrolfile.ctl';

NOTE: The default value for the snapshot control file name is platform-specific and
dependent on the Oracle home. For example, the default on some UNIX system
is?/dbs/[email protected]. If you clear the control file name, and you change the Oracle home,
then the default location of the snapshot control file changes as well.

As RMAN needs a consistent view of the control file it takes a backup of the controlfile by
creating a snapshot and during the backup RMAN uses the snapshot of the controlfile. By
default the snapshot controlfile is created in $ORACLE_HOME/dbs/snapcf_ORACLE_SID.f
which can be changed by setting the following parameter in RMAN
$ rman target /
display parameter value
RMAN> show all;
..
CONFIGURE SNAPSHOT CONTROLFILE NAME TO
'/u01/10.2.0.4/TESTDB/snapcf_TESTDB.f'; # default
set to new path for controlfile snapshot
RMAN> CONFIGURE SNAPSHOT CONTROLFILE NAME TO
'/u02/TESTDB/snapcf_TESTDB.f';

When multiple RMAN are running one could run into an issue RMAN-08512 where RMAN is
waiting for getting a lock on snapshot controlfile header. To find the session run the
following SQL.
SELECT vs.sid, vs.username, vs.program, vs.module, TO_CHAR(vs.logon_time, 'DDMON-YYYY HH24:MI:SS')
FROM v$session vs, v$enqueue_lock vel
WHERE vs.sid = vel.sid AND vel.type = 'CF' AND vel.id1 = 0 AND vel.id2 = 2

Configuring the Snapshot Control File


The snapshot control fileis a temporary file that is created at a certain location
specified over the operating system. This file is used by RMAN to synchronize the
information with the current control file. This file, except for synchronizing the
information with the current control file, does not do anything else and hence, is not
included in the recovery catalog. It does not contain any information about the
current backup that you have taken, though it does know about the last backups that
were done and are not marked yet as obsolete. So this file can be used to recover a
scenario where you have lost everything and also were not using the catalog. You can
use the last backup information recorded in this file and can recover the database with
that backup.
The location of this file depends on the platform and also uses a default naming
convention as well. Interestingly, irrespective of the flash recovery area being
configured, the snapshot control file does not use it and is set for the location,
normally to the ORACLE_HOME/database or ORACLE_HOME/dbs location with
the name sncf<sid>.ora.
You can see the current name and location of the file by the show command.
RMAN> show snapshot controlfile name;

RMAN configuration parameters are:


configure snapshot controlfile name to 'E:\ORACLE\product\10.2.0\db_1\database\sncforcl.ora'; #
default

In this case, it is set to the default location. You can change it using the configure
command.

2)
How To Register Older Backups To RMAN
Catalog
W henever backups were taken using the OS utility the backup information is not updated in the
repository.Only the backups taken using rman utility were updated in the catalog.To update the catalog about
the backup information took @ os level we can use the catalog command.
.

Cataloging Older Files in the Recovery Catalog


RMAN> CATALOG DATAFILECOPY '/disk1/old_datafiles/01_01_2003/users01.dbf';
RMAN> CATALOG ARCHIVELOG '/disk1/arch_logs/archive1_731.dbf', '/disk1/arch_logs/archive1_732.dbf';
RMAN> CATALOG BACKUPPIECE '/disk1/backups/backup_820.bkp';
You can also catalog multiple backup files in a directory at once, using the CATALOG START WITH command, as
shown in this example:
RMAN> CATALOG START WITH '/disk1/backups/';
RMAN lists the files to be added to the RMAN repository and prompts for confirmation before adding the backups.
Be careful when creating your prefix for CATALOG START WITH. RMAN scans all paths for all files on disk which
begin with your specified prefix. The wrong prefix may include more files than you intend. For example, a group of
directories /disk1/backups , /disk1/backups-year2003, /disk1/backupsets, and /disk1/backupsets/test and so on,
all contain backup files. The command
RMAN> CATALOG START WITH '/disk1/backups';
catalogs all files in all of these directories, because /disk1/backups is a prefix for the paths for all of these
directories. In order to catalog only backups in the /disk1/backups directory, the correct command would be:
RMAN> CATALOG START WITH '/disk1/backups/';

3)
How to catalog and uncatalog a backup to
RMAN repository

4) Catalog Backup
Whenever we take any backup through RMAN, in the repository information of the backup is
recorded. The RMAN respository can be either controlfile or recovery catalog. However if I take a
backup through OS command then RMAN does not aware of that and hence recorded are not
reflected in the repository. This is also true whenever we create a new controlfile or a backup
taken by RMAN is transferred to another place using OS command then controlfile/recovery
catalog does not know about the prior backups of the database. So in order to restore database
with a new created controlfile we need to inform RMAN about the backups taken before so that it
can pick one to restore.
This task can be done by catalog command in RMAN. With catalog command it can
-Add information of backup pieces and image copies in the repository that are on disk.
-Record a datafile copy as a level 0 incremental backup in the RMAN repository.
-Record of a datafile copy that was taken by OS.

But CATALOG command has some restrictions. It can't do the following.


-Can't catalog a file that belong to different database.
-Can't catalog a backup piece that exists on an sbt device.
Examples of Catalog command
1)Catalog an archive log: To catalog two archived logs named
/oracle/oradata/arju/arc001_223.arc and /oracle/oradata/arju/arc001_224.arc the command is,
RMAN>CATALOG ARCHIVELOG '/oracle/oradata/arju/arc001_223.arc',
'/oracle/oradata/arju/arc001_224.arc';
2)Catalog a file copy as an incremental backup: To catalog datafile copy
'/oradata/backup/users01.dbf' as an incremental level 0 backup your command will be,
RMAN>CATALOG DATAFILECOPY '/oradata/backup/users01.dbf' LEVEL 0;
Note that this datafile copy was taken backup either using the RMAN BACKUP AS COPY
command, or by using operating system utilities in conjunction with ALTER TABLESPACE
BEGIN/END BACKUP.
3)Catalog multiple copies in a directory: To catalog all valid backups from directory
/tmp/backups issue,
RMAN>CATALOG START WITH '/tmp/backups' NOPROMPT;
4)Catalog files in the flash recovery area: To catalog all files in the currently enabled flash
recovery area without prompting the user for each one issue,
RMAN>CATALOG RECOVERY AREA NOPROMPT;
5)Catalog backup pieces: To catalog backup piece /oradata2/o4jccf4 issue,
RMAN>CATALOG BACKUPPIECE '/oradata2/o4jccf4';
Uncatalog Backup
In many cases you need to uncatalog command. Suppose you do not want a specific backup or
copy to be eligible to be restored but also do not want to delete it.
To uncatalog all archived logs issue,
RMAN>CHANGE ARCHIVELOG ALL UNCATALOG;
To uncataog tablespace USERS issue,
RMAN>CHANGE BACKUP OF TABLESPACE USERS UNCATALOG;
To uncatalog a backuppiece name /oradata2/oft7qq issue,
RMAN>CHANGE BACKUPPIECE '/oradata2/oft7qq' UNCATALOG

5)

What is Database Incarnation ?

6)
7)

Database incarnation is effectively a new version of the database that happens when you reset the online
redo logs using alter database open resetlogs;.

8)

Database incarnation falls into following category Current, Parent, Ancestor andSibling

9)

i) Current Incarnation : The database incarnation in which the database is currently generating redo.

10) ii) Parent Incarnation : The database incarnation from which the current incarnation branched following
an OPEN RESETLOGS operation.
11) iii) Ancestor Incarnation : The parent of the parent incarnation is an ancestor incarnation. Any parent of
an ancestor incarnation is also an ancestor incarnation.
12) iv) Sibling Incarnation : Two incarnations that share a common ancestor are sibling incarnations if
neither one is an ancestor of the other.
.
Q. How to view incarnation history of Database ?
13) Using SQL> select * from v$database_incarnation;
Using RMAN>LIST INCARNATION;
14) However, you can use the RESET DATABASE TO INCARNATION command to specify that SCNs are to
be interpreted in the frame of reference of another incarnation.
15) For example my current database INCARNATION is 3 and now I have used
FLASHBACK DATABASE TO SCN 3000;then SCN 3000 will be search in current incarnation which is 3.
However if I want to get back to SCN 3000 of INCARNATION 2 then I have to use,
16) RMAN> RESET DATABASE TO INCARNATION 2;
RMAN> RECOVER DATABASE TO SCN 3000;

5) What do you mean by fractured blocks in oracle database?

Fractured block in Oracle


A block in which the header and footer are not consistent at a given SCN. In a usermanaged backup, an operating system utility can back up a datafile at the same time that DBWR is
updating the file. It is possible for the operating system utility to read a block in a half-updated state,
so that the block that is copied to the backup media is updated in its first half, while the second half
contains older data. In this case, the block is fractured.
For non-RMAN backups, the ALTER TABLESPACE ... BEGIN BACKUP or ALTER DATABASE
BEGIN BACKUP command is the solution for the fractured block problem. When a tablespace is
in backup mode, and a change is made to a data block, the database logs a copy of the entire block
image before the change so that the database can reconstruct this block if media recovery finds that
this block was fractured.
The block that the operating system reads can be split, that is, the top of the block is written at one
point in time while the bottom of the block is written at another point in time. If you restore a file
containing a fractured block and Oracle reads the block, then the block is considered a
corrupt.
What Happens When A Tablespace/Database Is Kept In Begin Backup Mode (Doc ID
469950.1)

6) What happens during the hot backup and why redolog generation is more during hot backups?
I am just trying to explain my little knowledge on hot backup process
During hot backup, a script or begin backup command puts a tablespace into backup mode, then copies the
datafiles to disk or tape, then takes the tablespace out of backup mode.
Many people are having a misconception regarding hot backup that, during hot backup DBWR process will
stop writing into datafiles. Also, they say that while the datafiles are not writable, changes are stored
somewhere in the SGA, the redologs, the rollback segments etc places and will be written back to datafiles
when the tablespace is taken out of backup mode.
In fact, Oracles tablespace hot backup does not work this way at all. It absolutely does not stop writing the
datafiles, and actually allows continued operation of the database almost exactly as during normal
operation.
1. The tablespace is checkpointed 2. The checkpoint SCN in the datafile header freeze to increment with
checkpoints 3. Full images of changed DB blocks are written to the redologs

The above three actions are all that is required to guarantee consistency once the file is restored and
recovery is applied. By freezing the checkpoint SCN in the file headers, any subsequent recovery on that
backup copy of the file will know that it must commence at that SCN. Having an old SCN in the file header
tells recovery that the file is an old one, and that it should look for the redolog file containing that SCN, and
apply recovery starting there. Note that checkpoints to datafiles in hot backup mode are not stopped during
the backup, only the incrementing of the main checkpoint SCN flag will stop increasing.
By initially checkpointing the datafiles that comprise the tablespace and logging full block images to redo,
Oracle guarantees that any blocks changed in the datafile while in hot backup mode will also be available in
the redologs in case they are ever used for a recovery.
Also we will observe that huge redo will be generated during hot backup. This is the result of the logging of
full images of changed blocks in these tablespaces to the redologs. Normally, Oracle logs an entry in the
redologs for every change in the database, but it does not log the whole image of the database block. By
logging full images of changed DB blocks to the redologs during backup mode, Oracle eliminates the
possibility of the backup containing fractured blocks. To understand this reasoning, you must first
understand what a fractured block is.
Typically, Oracle database blocks are a multiple of O/S blocks. For instance, most Unix filesystems have a
default block size of 4k, while Oracles default block size is 8k. This means that the filesystem stores data in
4k chunks, while Oracle performs reads and writes in 8k chunks, or multiples. While backing up a datafile,
your backup script makes a copy of the datafile from the filesystem, using O/S utilities such as copy, dd etc.
As it is making this copy, it is reading in O/S-block sized increments. If the database writer happens to be
writing a DB block into the datafile at the same time when backup is reading that block, your backup copy of
the DB block could contain some O/S blocks before and after writing by DBWR. This kind of blocks which are
having mismatched halves are called fractured blocks.
By logging the full block image of the changed block to the redologs, it guarantees that in the event of a
recovery, any fractured that might be in the backup copy of the datafile will be resolved by replacing them
with the full image of the block from the redologs.

7) What is the use of the crosscheck command and how to delete the expired backups?

When files are deleted @ os level using unix command the deletion information is not updated in the catalog. And
when you view the available backups it will show the non existing backups also as catalog will not get updated when

and reports to
locate "expired" or "obsolete" RMAN catalog entries we can use the crosscheck
command.
deletions happens @ os level. To update the catalog with the deletion information and also to

In other words crosscheck command is used to update the catalog with the available
physical backups by checking backups availability @ os level.

The RMAN crosscheck command is used when RMAN indicates that a file is
"missing:
RMAN> crosscheck backuppiece xxx;
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=xxx
crosschecked 1 objects

As we see the RMAN crosscheck command compares the RMAN catalog entries
with the actual OS files and reports to locate "expired" or "obsolete" RMAN catalog
entries.
Once a RMAN crosscheck identified expired, deleted on on obsolete catalog entries
you can run an RMAN delete command to remove these entries to synchronize the
RMAN catalog with the real database files:
RMAN> delete noprompt obsolete;

The RMAN crosscheck command can also be used to archive RMAN catalog entries:
crosscheck archivelog all ;

This crosscheck command is used then you get a RMAN-06059:


oracle> oerr RMAN 06059
RMAN-06059 expected archived log not found, loss of archived log compromises recoverability
Cause: The archived log was not found. The repository thinks it does exist. If the archived log
has in fact been lost and there is no backup, then the database is no longer recoverable across
the point in time covered by the archived log. This may occur because the archived log was
removed by an outside utility without updating the repository.
Action: If the archived log has been removed with an outside utility and the archivelog has
already been backed up, then you can synchronize the repository by running CROSSCHECK ARCHIVELOG
ALL. If the archivelog has not been previously backed up, then you should take a full backup of
the database and archivelogs to preserve recoverability. Previous backups are not fully
recoverable.

The syntax for the RMAN crosscheck command is simple:


allocate channel ch1 type disk ;
crosscheck archivelog all ;
release channel ch1 ;

Today I have to rebuild a physical standby database because there is a gap between primary and
standby. After I deleted the previous full backup used to create the standby, I need to use crosscheck
backup and delete expired backup to remove the information about the deleted backup recorded in
primarys control file:
ora1024@cnrac1:/home/ora1024/stage> rman target /
Recovery Manager: Release 11.1.0.6.0 - Production on Thu Jun 2 14:06:15 2011
Copyright (c) 1982, 2007, Oracle.

All rights reserved.

connected to target database: LAKERS (DBID=1270013502)


RMAN> crosscheck backup;
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=108 device type=DISK
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/home/ora1024/stage/Database01mb9q77_1_1 RECID=1 STAMP=750053608
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/home/ora1024/stage/Database02mb9q7h_1_1 RECID=2 STAMP=750053619
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/home/ora1024/stage/Database03mb9q98_1_1 RECID=3 STAMP=750053674
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/home/ora1024/stage/Database04mb9q9c_1_1 RECID=4 STAMP=750053676
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/home/ora1024/stage/Control05mb9qa0_1_1 RECID=5 STAMP=750053697
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/ora1024/product/11.1.0/db_1/dbs/16mc1k3a_1_1 RECID=35
STAMP=750833775
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/ora1024/product/11.1.0/db_1/dbs/17mc1ka7_1_1 RECID=36
STAMP=750833996
Crosschecked 7 objects
RMAN> delete expired backup;
using channel ORA_DISK_1
List of Backup Pieces
BP Key BS Key Pc# Cp# Status

Device Type Piece Name

------- ------- --- --- ----------- ----------- ---------1


1
1
1
EXPIRED
DISK
/home/ora1024/stage/Database01mb9q77_1_1
2
2
1
1
EXPIRED
DISK
/home/ora1024/stage/Database02mb9q7h_1_1
3
3
1
1
EXPIRED
DISK
/home/ora1024/stage/Database03mb9q98_1_1
4
4
1
1
EXPIRED
DISK
/home/ora1024/stage/Database04mb9q9c_1_1
5
5
1
1
EXPIRED
DISK
/home/ora1024/stage/Control05mb9qa0_1_1

Do you really want to delete the above objects (enter YES or NO)? yes
deleted backup piece
backup piece handle=/home/ora1024/stage/Database01mb9q77_1_1 RECID=1 STAMP=750053608
deleted backup piece
backup piece handle=/home/ora1024/stage/Database02mb9q7h_1_1 RECID=2 STAMP=750053619
deleted backup piece
backup piece handle=/home/ora1024/stage/Database03mb9q98_1_1 RECID=3 STAMP=750053674
deleted backup piece
backup piece handle=/home/ora1024/stage/Database04mb9q9c_1_1 RECID=4 STAMP=750053676
deleted backup piece
backup piece handle=/home/ora1024/stage/Control05mb9qa0_1_1 RECID=5 STAMP=750053697
Deleted 5 EXPIRED objects

check whether backup pieces, proxy copies, or disk copies still exist in comparison to
the control file's repository.
Syntax:
CROSSCHECK
{
{ BACKUP [OF listObjList]
| COPY [OF listObjList]
| archivelogRecordSpecifier
} [maintQualifier [maintQualifier]]
| recordSpec [DEVICE TYPE deviceSpecifier [,
deviceSpecifier]]
};
listObjList::=
[ DATAFILE datafileSpec [, datafileSpec]
| TABLESPACE ['] tablespace_name ['] [, [']
tablespace_name [']]
| archivelogRecordSpecifier
| DATABASE [SKIP TABLESPACE ['] tablespace_name [']
[, ['] tablespace_name [']]]
| CONTROLFILE
| SPFILE
]

Use RMAN Crosscheck to check that files are in place ready for a restore.
To validate a restore has worked, use the RMAN restore validate command.
Examples:
Assuming you have configured automatic channels:
RMAN>
RMAN>
RMAN>
RMAN>
RMAN>

CROSSCHECK
CROSSCHECK
CROSSCHECK
CROSSCHECK
CROSSCHECK

BACKUP;
COPY;
backup of database;
backup of controlfile;
archivelog all;

Query the media manager for the status of backup sets in a given date range:
RMAN> ALLOCATE CHANNEL FOR MAINTENANCE DEVICE TYPE sbt;
RMAN> CROSSCHECK BACKUP DEVICE TYPE sbt COMPLETED BETWEEN '01AUG-04' AND '31-DEC-04';
"Wealth heaped on wealth, nor truth nor safety buys,
The dangers gather as the treasures rise" - Samuel Johnson: The Vanity Of Human
Wishes
Related Commands:
RMAN Restore Validate
RMAN CHANGE - Update the status of a backup in the RMAN repository.
RMAN CONFIGURE - Persistent RMAN settings.
RMAN DELETE - Delete backups from disk or tape
RMAN LIST - List backups and copies
RMAN REPORT - Report backup status: database, files, backups
NLS_DATE_FORMAT parameter
Related Views:
RC_BACKUP_FILES V$BACKUP_FILES
repository.
RC_BACKUP_PIECE V$BACKUP_PIECE

RMAN backups and copies in the


Backup pieces

8) What is the use of set new name for command in rman ?

As default, RMAN restores a backup of a datafile to its default location. To change


this behavior, use the set newname command to define a new location for the restored
datafile.
Prior to Oracle 11gR2, this command was used to rename the datafiles and tempfiles.
But starting from Oracle 11gR2, you can rename all datafiles in any tablespace and
even the whole database files. Moreover, these new options come with new
substitution variables which help to change the set of filenames at once. See the usage
of these options and substitution variables in real examples.

Using set newname for datafile

RMAN> run
{
set newname for datafile 4 to '/tmp/datafile4.dbf';
restore datafile 4;
}
executing command: set newname
channel ORA_DISK_1: restoring datafile 00004 to /tmp/datafile4.dbf

Using set newname for tempfile

To create a tempfile in a new directory while cloning the database, use the set
newname for tempfile to ?. command as follows:
RMAN> run
{
set newname for tempfile 1 to /tmp/temp01.dbf';
duplicate database;
}

RMAN will create a new tempfile with a specified name after the database is
recovered and opened.

Using set newname for tablespace

This option is used to change all datafiles in a specified tablespace. When using this
option, you must use a substitution variable to avoid name collisions. Here is the list
of substitution variables which are used during name conversion:

%b: Specifies the file name without the directory that it locates.
%N: Specifies the tablespace name
%f: Specifies the absolute file number of a datafile
%I: Specifies DBID

%U: Specifies system generated unique filename as a following format: dataD-%d_id-%I_TS-%N_FNO-%f

See the following example to understand these substitution variables. In the following
example, the %b, %N and %f variables are used:
RMAN> run
2> {
3> set newname for tablespace users to '/tmp/db/%n_%f_%b';
4> restore tablespace users;
5> }
output file name=/tmp/db/USERS_4_users01.dbf RECID=8 STAMP=728496167
output file name=/tmp/db/USERS_5_user02.dbf RECID=9 STAMP=728496168

By using the %U variable, you can get the system-generated unique filename. Look at
the following example:
RMAN> run
2> {
3> set newname for tablespace users to '/tmp/db/%u';
4> restore tablespace users;
5> }
output file name=/tmp/db/data_d-test_ts-users_fno-4 recid=10
stamp=728496242
output file name=/tmp/db/data_d-test_ts-users_fno-5 recid=11 stamp=728496243

Using set newname for database

This option is used to set a new name for all datafiles and tempfiles in a database. This
option is also used with one of the above mentioned substitution variables.
9) How do you know that how much RMAN task has been completed?

By querying v$rman_status or v$session_longops


10) What is the difference between using recovery catalog and control file?

When new incarnation happens, the old backup information in control file will be lost. It will be preserved
in recovery catalog.
In recovery catalog we can store scripts.
Recovery catalog is central and can have information of many databases.
11) Command to delete archive logs older than 7days?

RMAN> delete archivelog all completed before sysdate-7

12) What is the use of crosscheck command in RMAN?

Crosscheck will be useful to check whether the catalog information is intact with OS level information.
This command only updates repository records with the status of the backups.
e.g. If user removes archived logs from disk with an operating system command, the repository still
indicates that the logs are on disk, when in fact they are not.
13) What are the differences between crosscheck and validate commands?

Validate command is to examine a backup set and report whether it can be restored. RMAN scans all of
the backup pieces in the specified backup sets and looks at the checksum to verify that the contents are
intact so that backup can be successfully restored if necessary.
Crosscheck command is to verify the status of backups and copies recorded in the RMAN repository
against media such as disk or tape. The crosscheck command only processes files created on the same
device type as the channel running crosscheck.
14) What is obsolete backup & expired backup?

A status of expired means that the backup piece or backup set is not found in the backup destination.
A status of obsolete means the backup piece is still available, but it is no longer needed. The backup
piece is no longer needed since RMAN has been configured to no longer need this piece after so many
days have elapsed, or so many backups have been performed.
What is the difference between hot backup & RMAN backup?
For hot backup, we have to put database in begin backup mode, then take backup.
RMAN wont put database in backup mode.

15) In catalog database, if some of the blocks are corrupted due to system crash, How will you

recover?
using RMAN BLOCK RECOVER command

16) Using v$block_corruption view you can find which blocks corrupted.

RMAN> block recover datafile <fileid> block <blockid>;

Using the above statement You recover the corrupted blocks. First check whether the block is corrupted
or not by using this command
SQL>select file# block# from v$database_block_corruption;
file# block
2 507
the above block is corrupted
conn to Rman
To recover the block use this command
RMAN>blockrecover datafile 2 block 507;
the above command recover the block 507
Now just verify it..
Rman>blockrecover corruption list;

17) 21. How to put

manual/user-managed backup in RMAN (recovery catalog)?

By using catalog command.


RMAN> CATALOG START WITH '/tmp/backup.ctl';

18) What is meant by change vectors in oracle database ?

Redo log files are filled with redo records. A redo record, also called a redo entry, is made up of a
group of change vectors, each of which is a description of a change made to a single block in the
database. For example, if you change a salary value in an employee table, you generate a redo
record containing change vectors that describe changes to the data segment block for the table,
the undo segment data block, and the transaction table of the undo segments.

Change vector is the redo entry of Log buffer. It is generated with every DML operation and
stored in log buffer for keeping track of every transaction of database (database changes).

Oracle Internals Notes

Change Vectors
A logically atomic database change to an Oracle database normally consists of two or
more physical block changes. For example, inserting a row into a table may involve
changes to several index blocks, as well as a change to one of the blocks of the table
itself. And for most block changes, there must be a corresponding change to at least
one rollback segment block. There may also be changes required to a rollback
segment header block, block cleanouts, freelist changes, and so on.
Before making a database change, a process must take buffer locks on each of the
buffers holding the current mode image of the database blocks affected, and prepare a
set of change vectors representing the intended changes -- one for each physical
database change. Before the set of change vectors can be applied to the database
blocks, they must all be copied into the redo stream as a single redo record. Redo
records are sometimes called redo entries.

Ixora Pty Ltd. All rights reserved.


12-Oct-2007 22:22

19) What is meant by partition pruning in oracle database?

One very useful feature about partitioning that is available since version 8 is the possibility
of partition pruning. That means, that the optimizer during the parse phase of a SQL statement is
able to exclude certain partitions from scanning because according to the definition of the
partitioned table present in the Data Dictionary, the desired rows cant be in those partitions.
When we for example have a table that is partitioned by range on a date column with one
partition for each quarter of the year, it is implicitly clear for a query like
select * from t where time_id=to_date('01-01-2009','dd-mm-yyyy');

some tables are so large that a Full Table Scan is unthinkable. If these tables are
not partitioned, they should be.
The most common (by far) form of partitioning is Range Partitioning on a DATE
column. For example, a table may be partitioned on TXN_DATE, with a separate
partition for each year, month, or even day (I have seen a multi-terabyte database
where daily partitions were the norm!).
If Oracle can use the WHERE predicates to eliminate some partitions from a search,
then it probably will. This is called Partition Pruning. For example:
SELECT *
FROM my_big_partition_table
WHERE calendar_date = :b1
SELECT STATEMENT
PARTITION RANGE SINGLE
TABLE ACCESS FULL MY_BIG_PARTITION_TABLE
SELECT *
FROM my_big_partition_table
WHERE calendar_date >= :b1
SELECT STATEMENT
PARTITION RANGE ITERATOR
TABLE ACCESS FULL MY_BIG_PARTITION_TABLE

Partition Pruning
This section discusses an optimization known as partition pruning. The core concept behind partition
pruning is relatively simple, and can be described as Do not scan partitions where there can be no
matching values. Suppose that you have a partitioned table t1 defined by this statement:
CREATE TABLE t1 (
fname VARCHAR(50) NOT NULL,
lname VARCHAR(50) NOT NULL,
region_code TINYINT UNSIGNED NOT NULL,
dob DATE NOT NULL
)
PARTITION BY RANGE( region_code ) (
PARTITION p0 VALUES LESS THAN (64),
PARTITION p1 VALUES LESS THAN (128),

PARTITION p2 VALUES LESS THAN (192),


PARTITION p3 VALUES LESS THAN MAXVALUE
);

Consider the case where you wish to obtain results from a SELECT statement such as this one:
SELECT fname, lname, region_code, dob
FROM t1
WHERE region_code > 125 AND region_code < 130;

It is easy to see that none of the rows which ought to be returned will be in either of the
partitions p0 or p3; that is, we need to search only in partitions p1 and p2 to find matching rows. By
doing so, it is possible to expend much less time and effort in finding matching rows than would be
required to scan all partitions in the table. This cutting awayof unneeded partitions is known
as pruning. When the optimizer can make use of partition pruning in performing this query, execution
of the query can be an order of magnitude faster than the same query against a nonpartitioned table
containing the same column definitions and data.
http://docs.oracle.com/cd/E17952_01/refman-5.5-en/partitioningpruning.html

You might also like