DBA Interview Questions & Answers
1.What are the responsibilities of a Database Administrator ?
Installing and upgrading the
Oracle Server and application tools. Allocating system storage and planning
future storage requirements for the database system. Managing primary database
structures (tablespaces) Managing primary objects (table,views,indexes)
Enrolling users and maintaining system security. Ensuring compliance with Oracle license agreement Controlling and monitoring user access to the
database. Monitoring and optimizing the performance of the database. Planning
for backup and recovery of database information. Maintain archived data on tape
Backing up and restoring the database. Contacting Oracle Corporation for
technical support.
2.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.
3. 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.
4. 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.
5. What command would you use to
create a backup control file?
Alter database backup control
file to trace.
6. 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.
7. 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.
8. When a user process fails,
what background process cleans up after it?
PMON
9. What background process
refreshes materialized views?
The Job Queue Processes.
10. How would you determine what
sessions are connected and what resources they are waiting for?
Use of V$SESSION and
V$SESSION_WAIT
11. Describe what redo logs are?
Redo logs are logical and
physical structures that are designed to hold all the changes made to a
database and are intended to aid in the recovery of a database.
12. How would you force a log
switch?
ALTER SYSTEM SWITCH LOG FILE;
13. Name a table-space automatically created when
you create a database?
The SYSTEM table-space.
14. What are the minimum parameters should
exist in the parameter file (init.ora) ?
DB NAME - Must set to a text string of no more than 8 characters and it will be
stored inside the datafiles, redo log files and control files and control file
while database creation.
DB_DOMAIN - It is string that specifies the network domain where the database
is created. The global database name is identified by setting these parameters
(DB_NAME & DB_DOMAIN) CONTORL FILES - List of control filenames of the
database. If name is not mentioned then default name will be used.
DB_BLOCK_BUFFERS - To determine the no of buffers in the buffer cache in SGA.
PROCESSES - To determine number of operating system processes that can be
connected to ORACLE concurrently. The value should be 5 (background process)
and additional 1 for each user.
ROLLBACK_SEGMENTS - List of rollback segments an ORACLE instance acquires at
database startup. Also optionally LICENSE_MAX_SESSIONS,LICENSE_SESSION_WARNING
and LICENSE_MAX_USERS.
15. Can one rename a tablespace?
No, this is listed as
Enhancement Request 148742. Workaround:
Export all of the objects from the tablespace
Drop the tablespace including contents
Recreate the tablespace
Import the objects
16. Can one resize tablespaces
and data files?
One can manually increase or
decrease the size of a datafile from Oracle 7.2 using the command.
ALTER DATABASE DATAFILE 'filename2' RESIZE 100M;
Because you can change the sizes of datafiles, you can add more space to your
database without adding more datafiles. This is beneficial if you are concerned
about reaching the maximum number of datafiles allowed in your database.
Manually reducing the sizes of datafiles allows you to reclaim unused space in
the database. This is useful for correcting errors in estimations of space
requirements.
Also, datafiles can be allowed to automatically extend if more space is
required. Look at the following command:
CREATE TABLESPACE pcs_data_ts
DATAFILE 'c:\ora_apps\pcs\pcsdata1.dbf' SIZE 3M
AUTOEXTEND ON NEXT 1M MAXSIZE UNLIMITED
DEFAULT STORAGE (INITIAL 10240
NEXT 10240
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0)
ONLINE
PERMANENT;
17. Why and when should I backup
my database?
Backup and recovery is one of
the most important aspects of a DBAs 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
. 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 miscommunications.
18. 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 process 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;
19. When creating a user, what permissions must you
grant to allow them to connect to the database?
Grant the CONNECT to the user.
20. What is STATSPACK and how does one use it?
Statspack is a set of performance monitoring and reporting utilities provided
by Oracle from Oracle8i and above. Statspack provides improved BSTAT/ESTAT
functionality, though the old BSTAT/ESTAT scripts are still available. For more
information about STATSPACK, read the documentation in file
$ORACLE_HOME/rdbms/admin/spdoc.txt.
Install Statspack:
cd $ORACLE_HOME/rdbms/admin
sqlplus "/ as sysdba" @spdrop.sql -- Install Statspack -
sqlplus "/ as sysdba" @spcreate.sql-- Enter tablespace names when
prompted
Use Statspack:
sqlplus perfstat/perfstat
exec statspack.snap; -- Take a performance snapshots
exec statspack.snap;
o Get a list of snapshots
select SNAP_ID, SNAP_TIME from STATS$SNAPSHOT;
@spreport.sql -- Enter two snapshot id's for difference report
Other Statspack Scripts:
. sppurge.sql - Purge a range of Snapshot Id's between the specified begin and
end Snap Id's
. spauto.sql - Schedule a dbms_job to automate the collection of STATPACK
statistics
. spcreate.sql - Installs the STATSPACK user, tables and package on a database
(Run as SYS).
. spdrop.sql - Deinstall STATSPACK from database (Run as SYS)
. sppurge.sql - Delete a range of Snapshot Id's from the database
. spreport.sql - Report on differences between values recorded in two snapshots
. sptrunc.sql - Truncates all data in Statspack tables
21. How do you add a data file
to a tablespace?
ALTER TABLESPACE <tablespace_name> ADD DATAFILE
<datafile_name> SIZE
22. What is SAVE
POINT?
For long transactions that contain many SQL statements,
intermediate markers or savepoints can be declared which can be used to divide
a transaction into smaller parts. This allows the option of later rolling back
all work performed from the current point in the transaction to a declared
savepoint within the transaction.
23. What is mean by Program Global Area (PGA)?
It is area in memory that is used by a Single Oracle User Process.
24. How does one
manage Oracle database users?
Oracle user accounts can be locked, unlocked, forced to
choose new passwords, etc. For example, all accounts except SYS and SYSTEM will
be locked after creating an Oracle9iDB database using the DB Configuration
Assistant (dbca). DBA's must unlock these accounts to make them available to
users.
Look at these examples:
ALTER USER scott ACCOUNT LOCK -- lock a user account
ALTER USER scott ACCOUNT UNLOCK; -- unlocks a locked users account
ALTER USER scott PASSWORD EXPIRE; -- Force user to choose a new password
25. How does one
tune Oracle Wait events?
Some wait events from V$SESSION_WAIT and V$SYSTEM_EVENT
views:
2.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.
3. 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.
4. 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.
6. 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.
7. 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.
13. Name a table-space automatically created when you create a database?
The SYSTEM table-space.
14. What are the minimum parameters should exist in the parameter file (init.ora) ?
DB NAME - Must set to a text string of no more than 8 characters and it will be stored inside the datafiles, redo log files and control files and control file while database creation.
DB_DOMAIN - It is string that specifies the network domain where the database is created. The global database name is identified by setting these parameters
(DB_NAME & DB_DOMAIN) CONTORL FILES - List of control filenames of the database. If name is not mentioned then default name will be used.
DB_BLOCK_BUFFERS - To determine the no of buffers in the buffer cache in SGA.
PROCESSES - To determine number of operating system processes that can be connected to ORACLE concurrently. The value should be 5 (background process) and additional 1 for each user.
ROLLBACK_SEGMENTS - List of rollback segments an ORACLE instance acquires at database startup. Also optionally LICENSE_MAX_SESSIONS,LICENSE_SESSION_WARNING and LICENSE_MAX_USERS.
Export all of the objects from the tablespace
Drop the tablespace including contents
Recreate the tablespace
Import the objects
ALTER DATABASE DATAFILE 'filename2' RESIZE 100M;
Because you can change the sizes of datafiles, you can add more space to your database without adding more datafiles. This is beneficial if you are concerned about reaching the maximum number of datafiles allowed in your database.
Manually reducing the sizes of datafiles allows you to reclaim unused space in the database. This is useful for correcting errors in estimations of space requirements.
Also, datafiles can be allowed to automatically extend if more space is required. Look at the following command:
CREATE TABLESPACE pcs_data_ts
DATAFILE 'c:\ora_apps\pcs\pcsdata1.dbf' SIZE 3M
AUTOEXTEND ON NEXT 1M MAXSIZE UNLIMITED
DEFAULT STORAGE (INITIAL 10240
NEXT 10240
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0)
ONLINE
PERMANENT;
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
. 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 miscommunications.
18. 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 process 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;
19. When creating a user, what permissions must you grant to allow them to connect to the database?
Grant the CONNECT to the user.
20. What is STATSPACK and how does one use it?
Statspack is a set of performance monitoring and reporting utilities provided by Oracle from Oracle8i and above. Statspack provides improved BSTAT/ESTAT functionality, though the old BSTAT/ESTAT scripts are still available. For more information about STATSPACK, read the documentation in file $ORACLE_HOME/rdbms/admin/spdoc.txt.
Install Statspack:
cd $ORACLE_HOME/rdbms/admin
sqlplus "/ as sysdba" @spdrop.sql -- Install Statspack -
sqlplus "/ as sysdba" @spcreate.sql-- Enter tablespace names when prompted
Use Statspack:
sqlplus perfstat/perfstat
exec statspack.snap; -- Take a performance snapshots
exec statspack.snap;
o Get a list of snapshots
select SNAP_ID, SNAP_TIME from STATS$SNAPSHOT;
@spreport.sql -- Enter two snapshot id's for difference report
Other Statspack Scripts:
. sppurge.sql - Purge a range of Snapshot Id's between the specified begin and end Snap Id's
. spauto.sql - Schedule a dbms_job to automate the collection of STATPACK statistics
. spcreate.sql - Installs the STATSPACK user, tables and package on a database (Run as SYS).
. spdrop.sql - Deinstall STATSPACK from database (Run as SYS)
. sppurge.sql - Delete a range of Snapshot Id's from the database
. spreport.sql - Report on differences between values recorded in two snapshots
. sptrunc.sql - Truncates all data in Statspack tables
23. What is mean by Program Global Area (PGA)?
It is area in memory that is used by a Single Oracle User Process.
Look at these examples:
ALTER USER scott ACCOUNT LOCK -- lock a user account
ALTER USER scott ACCOUNT UNLOCK; -- unlocks a locked users account
ALTER USER scott PASSWORD EXPIRE; -- Force user to choose a new password
Event Name:
|
Tuning Recommendation:
|
db file sequential read
|
Tune SQL to do less I/O. Make sure all objects are
analyzed. Redistribute I/O across disks.
|
buffer busy waits
|
Increase DB_CACHE_SIZE (DB_BLOCK_BUFFERS prior to 9i)/
Analyze contention from SYS.V$BH
|
log buffer spaces
|
Increase LOG_BUFFER parameter or move log files to faster
disks
|
26. Can one monitor
how fast a table is imported?
If you need to monitor how fast rows are imported from a
running import job, try one of the following methods:
Method 1:
select substr(sql_text,instr(sql_text,'INTO "'),30) table_name,
rows_processed,
round((sysdate-to_date(first_load_time,'yyyy-mm-dd hh24:mi:ss'))*24*60,1) minutes,
trunc(rows_processed/((sysdate-to_date(first_load_time,'yyyy-mm-dd hh24:mi:ss'))*24*60)) rows_per_min
from sys.v_$sqlarea
where sql_text like 'INSERT %INTO "%'
and command_type = 2
and open_versions > 0;
For this to work one needs to be on Oracle 7.3 or higher (7.2 might also be OK). If the import has more than one table, this statement will only show information about the current table being imported.
Contributed by Osvaldo Ancarola, Bs. As. Argentina.
Method 2:
Use the FEEDBACK=n import parameter. This command will tell IMP to display a dot for every N rows imported.
Method 1:
select substr(sql_text,instr(sql_text,'INTO "'),30) table_name,
rows_processed,
round((sysdate-to_date(first_load_time,'yyyy-mm-dd hh24:mi:ss'))*24*60,1) minutes,
trunc(rows_processed/((sysdate-to_date(first_load_time,'yyyy-mm-dd hh24:mi:ss'))*24*60)) rows_per_min
from sys.v_$sqlarea
where sql_text like 'INSERT %INTO "%'
and command_type = 2
and open_versions > 0;
For this to work one needs to be on Oracle 7.3 or higher (7.2 might also be OK). If the import has more than one table, this statement will only show information about the current table being imported.
Contributed by Osvaldo Ancarola, Bs. As. Argentina.
Method 2:
Use the FEEDBACK=n import parameter. This command will tell IMP to display a dot for every N rows imported.
27. Can one import
tables to a different tablespace?
Oracle offers no parameter to specify a different tablespace
to import data into. Objects will be re-created in the tablespace they were
originally exported from. One can alter this behaviour by following one of
these procedures: Pre-create the table(s) in the correct tablespace:
. Import the dump file using the INDEXFILE= option
. Edit the indexfile. Remove remarks and specify the correct tablespaces.
. Run this indexfile against your database, this will create the required tables in the appropriate tablespaces
. Import the table(s) with the IGNORE=Y option.
Change the default tablespace for the user:
. Import the dump file using the INDEXFILE= option
. Edit the indexfile. Remove remarks and specify the correct tablespaces.
. Run this indexfile against your database, this will create the required tables in the appropriate tablespaces
. Import the table(s) with the IGNORE=Y option.
Change the default tablespace for the user:
. Revoke the "UNLIMITED TABLESPACE" privilege from the user
. Revoke the user's quota from the tablespace from where the object was exported. This forces the import utility to create tables in the user's default tablespace.
. Make the tablespace to which you want to import the default tablespace for the user
. Import the table.
. Revoke the user's quota from the tablespace from where the object was exported. This forces the import utility to create tables in the user's default tablespace.
. Make the tablespace to which you want to import the default tablespace for the user
. Import the table.
28. What is
SQL*Loader and what is it used for?
SQL*Loader is a bulk loader utility used for moving data
from external files into the Oracle database. Its syntax is similar to that of
the DB2 Load utility, but comes with more options. SQL*Loader supports various
load formats, selective loading, and multi-table loads.
29. WHAT IS RMAN?
Recovery Manager is a tool that: manages the process of creating backups and also manages the process of restoring and recovering from them.
Recovery Manager is a tool that: manages the process of creating backups and also manages the process of restoring and recovering from them.
30. What is hit
ratio?
It is a measure of well the data cache buffer is handling
requests for data. Hit Ratio = (Logical Reads - Physical Reads - Hits Misses)/
Logical Reads.
31. WHY USE RMAN?
- No extra costs …Its available free
- RMAN introduced in Oracle 8 it has become simpler with newer versions and easier than user managed backups
- Proper security
- You are 100% sure your database has been backed up.
- Its contains detail of the backups taken etc in its central repository
- Facility for testing validity of backups also commands like crosscheck to check the status of backup.
- Faster backups and restores compared to backups without RMAN
- RMAN is the only backup tool which supports incremental backups.
- Oracle 10g has got further optimized incremental backup which has resulted in improvement of performance during backup and recovery time
- Parallel operations are supported
- Better querying facility for knowing different details of backup
- No extra redo generated when backup is taken..compared to online
- backup without RMAN which results in saving of space in hard disk
- RMAN an intelligent tool
- Maintains repository of backup metadata
- Remembers backup set location
- Knows what need to backed up
- Knows what is required for recovery
- Knows what backups are redundant
UNDERSTANDING THE RMAN
ARCHITECTURE
An oracle RMAN comprises of RMAN EXECUTABLE This could be present and fired even through client side TARGET DATABASE This is the database which needs to be backed up .RECOVERY CATALOG Recovery catalog is optional otherwise backup details are stored in target database controlfile .
It is a repository of information queried and updated by Recovery Manager
It is a schema or user stored in Oracle database. One schema can support many databases
It contains information about physical schema of target database datafile and archive log ,backup sets and pieces Recovery catalog is a must in following scenarios
. In order to store scripts . For tablespace point in time recovery
Media Management Software Media Management software is a must if you are using RMAN for storing backup in tape drive directly.
Backups in RMAN Oracle backups in RMAN are of the following type
RMAN complete backup OR RMAN incremental backup
These backups are of RMAN proprietary nature
IMAGE COPY The advantage of uing Image copy is its not in RMAN proprietary format..
Backup Format
RMAN backup is not in oracle format but in RMAN format. Oracle backup comprises of backup sets and it consists of backup pieces. Backup sets are logical entity In oracle 9i it gets stored in a default location There are two type of backup sets Datafile backup sets, Archivelog backup sets One more important point of data file backup sets is it do not include empty blocks. A backup set would contain many backup pieces.
A single backup piece consists of physical files which are in RMAN proprietary format.
Example of taking backup using RMAN
Taking RMAN Backup
In non archive mode in dos prompt type RMAN
You get the RMAN prompt
RMAN > Connect Target
Connect to target database : Magic
using target database controlfile instead of recovery catalog
Lets take a simple backup of database in non archive mode
shutdown immediate ; - - Shutdowns the database
startup mount
backup database ;- its start backing the database
alter database open;
We can fire the same command in archive log mode
And whole of datafiles will be backed
Backup database plus archivelog;
Restoring database
Restoring database has been made very simple in 9i .
It is just Restore database..
RMAN has become intelligent to identify which datafiles has to be restored
and the location of backuped up file.
Oracle Enhancement for RMAN in 10 G Flash Recovery Area
Right now the price of hard disk is falling. Many dba are taking oracle database backup inside the hard disk itself since it results in lesser mean time between recoverability.
The new parameter introduced is
DB_RECOVERY_FILE_DEST = /oracle/flash_recovery_area
By configuring the RMAN RETENTION POLICY the flash recovery area will automatically delete obsolete backups and archive logs that are no longer required based on that configuration Oracle has introduced new features in incremental backup
Change Tracking File
Oracle 10g has the facility to deliver faster incrementals with the implementation of changed tracking file feature.This will results in faster backups lesser space consumption and also reduces the time needed for daily backups
Incrementally Updated Backups
Oracle database 10g Incrementally Updates Backup features merges the image copy of a datafile with RMAN incremental backup. The resulting image copy is now updated with block changes captured by incremental backups.The merging of the image copy and incremental backup is initiated with RMAN recover command. This results in faster recovery.
Binary compression technique reduces backup space usage by 50-75%.
With the new DURATION option for the RMAN BACKUP command, DBAs can weigh backup performance against system service level requirements. By specifying a duration, RMAN will automatically calculate the appropriate backup rate; in addition, DBAs can optionally specify whether backups should minimize time or system load.
New Features in Oem to identify RMAN related backup like backup pieces, backup sets and image copy Oracle 9i New features Persistent RMAN Configuration A new configure command has been introduced in Oracle 9i , that lets you configure various features including automatic channels, parallelism ,backup options, etc.
These automatic allocations and options can be overridden by commands in a RMAN command file.
Controlfile Auto backups
Through this new feature RMAN will automatically perform a controlfile auto backup. after every backup or copy command.
Block Media Recovery
If we can restore a few blocks rather than an entire file we only need few blocks.
We even dont need to bring the data file offline.
Syntax for it as follows Block Recover datafile 8 block 22;
Configure Backup Optimization Prior to 9i whenever we backed up database using RMAN our backup also used take backup of read only table spaces which had already been backed up and also the same with archive log too.
Now with 9i backup optimization parameter we can prevent repeat backup of read only tablespace and archive log. The command for this is as follows Configure backup optimization on
Archive Log failover If RMAN cannot read a block in an archived log from a destination. RMAN automatically attempts to read from an alternate location this is called as archive log failover
There are additional commands like backup database not backed up since time '31-jan-2002 14:00:00'
Do not backup previously backed up files
(say a previous backup failed and you want to restart from where it left off).
Similar syntax is supported for restores
backup device sbt backup set all Copy a disk backup to tape
(backing up a backup
Additionally it supports
. Backup of server parameter file
. Parallel operation supported
. Extensive reporting available
. Scripting
. Duplex backup sets
. Corrupt block detection
. Backup archive logs
Pitfalls of using RMAN Previous to version Oracle 9i backups were not that easy which means you had to allocate a channel compulsorily to take backup You had to give a run etc . The syntax was a bit complex …RMAN has now become very simple and easy to use..
If you changed the location of backup set it is compulsory for you to register it using RMAN or while you are trying to restore backup It resulted in hanging situations
There is no method to know whether during recovery database restore is going to fail because of missing archive log file. Compulsory Media Management only if using tape backup
Incremental backups though used to consume less space used to be slower since it used to read the entire database to find the changed blocks and also They have difficult time streaming the tape device. .
Considerable improvement has been made in 10g to optimize the algorithm to handle changed block.
Observation :- Introduced in Oracle 8 it has become more powerful and simpler with newer version of Oracle 9 and 10 g. So if you really don't want to miss something critical please start using RMAN.
An oracle RMAN comprises of RMAN EXECUTABLE This could be present and fired even through client side TARGET DATABASE This is the database which needs to be backed up .RECOVERY CATALOG Recovery catalog is optional otherwise backup details are stored in target database controlfile .
It is a repository of information queried and updated by Recovery Manager
It is a schema or user stored in Oracle database. One schema can support many databases
It contains information about physical schema of target database datafile and archive log ,backup sets and pieces Recovery catalog is a must in following scenarios
. In order to store scripts . For tablespace point in time recovery
Media Management Software Media Management software is a must if you are using RMAN for storing backup in tape drive directly.
Backups in RMAN Oracle backups in RMAN are of the following type
RMAN complete backup OR RMAN incremental backup
These backups are of RMAN proprietary nature
IMAGE COPY The advantage of uing Image copy is its not in RMAN proprietary format..
Backup Format
RMAN backup is not in oracle format but in RMAN format. Oracle backup comprises of backup sets and it consists of backup pieces. Backup sets are logical entity In oracle 9i it gets stored in a default location There are two type of backup sets Datafile backup sets, Archivelog backup sets One more important point of data file backup sets is it do not include empty blocks. A backup set would contain many backup pieces.
A single backup piece consists of physical files which are in RMAN proprietary format.
Example of taking backup using RMAN
Taking RMAN Backup
In non archive mode in dos prompt type RMAN
You get the RMAN prompt
RMAN > Connect Target
Connect to target database : Magic
using target database controlfile instead of recovery catalog
Lets take a simple backup of database in non archive mode
shutdown immediate ; - - Shutdowns the database
startup mount
backup database ;- its start backing the database
alter database open;
We can fire the same command in archive log mode
And whole of datafiles will be backed
Backup database plus archivelog;
Restoring database
Restoring database has been made very simple in 9i .
It is just Restore database..
RMAN has become intelligent to identify which datafiles has to be restored
and the location of backuped up file.
Oracle Enhancement for RMAN in 10 G Flash Recovery Area
Right now the price of hard disk is falling. Many dba are taking oracle database backup inside the hard disk itself since it results in lesser mean time between recoverability.
The new parameter introduced is
DB_RECOVERY_FILE_DEST = /oracle/flash_recovery_area
By configuring the RMAN RETENTION POLICY the flash recovery area will automatically delete obsolete backups and archive logs that are no longer required based on that configuration Oracle has introduced new features in incremental backup
Change Tracking File
Oracle 10g has the facility to deliver faster incrementals with the implementation of changed tracking file feature.This will results in faster backups lesser space consumption and also reduces the time needed for daily backups
Incrementally Updated Backups
Oracle database 10g Incrementally Updates Backup features merges the image copy of a datafile with RMAN incremental backup. The resulting image copy is now updated with block changes captured by incremental backups.The merging of the image copy and incremental backup is initiated with RMAN recover command. This results in faster recovery.
Binary compression technique reduces backup space usage by 50-75%.
With the new DURATION option for the RMAN BACKUP command, DBAs can weigh backup performance against system service level requirements. By specifying a duration, RMAN will automatically calculate the appropriate backup rate; in addition, DBAs can optionally specify whether backups should minimize time or system load.
New Features in Oem to identify RMAN related backup like backup pieces, backup sets and image copy Oracle 9i New features Persistent RMAN Configuration A new configure command has been introduced in Oracle 9i , that lets you configure various features including automatic channels, parallelism ,backup options, etc.
These automatic allocations and options can be overridden by commands in a RMAN command file.
Controlfile Auto backups
Through this new feature RMAN will automatically perform a controlfile auto backup. after every backup or copy command.
Block Media Recovery
If we can restore a few blocks rather than an entire file we only need few blocks.
We even dont need to bring the data file offline.
Syntax for it as follows Block Recover datafile 8 block 22;
Configure Backup Optimization Prior to 9i whenever we backed up database using RMAN our backup also used take backup of read only table spaces which had already been backed up and also the same with archive log too.
Now with 9i backup optimization parameter we can prevent repeat backup of read only tablespace and archive log. The command for this is as follows Configure backup optimization on
Archive Log failover If RMAN cannot read a block in an archived log from a destination. RMAN automatically attempts to read from an alternate location this is called as archive log failover
There are additional commands like backup database not backed up since time '31-jan-2002 14:00:00'
Do not backup previously backed up files
(say a previous backup failed and you want to restart from where it left off).
Similar syntax is supported for restores
backup device sbt backup set all Copy a disk backup to tape
(backing up a backup
Additionally it supports
. Backup of server parameter file
. Parallel operation supported
. Extensive reporting available
. Scripting
. Duplex backup sets
. Corrupt block detection
. Backup archive logs
Pitfalls of using RMAN Previous to version Oracle 9i backups were not that easy which means you had to allocate a channel compulsorily to take backup You had to give a run etc . The syntax was a bit complex …RMAN has now become very simple and easy to use..
If you changed the location of backup set it is compulsory for you to register it using RMAN or while you are trying to restore backup It resulted in hanging situations
There is no method to know whether during recovery database restore is going to fail because of missing archive log file. Compulsory Media Management only if using tape backup
Incremental backups though used to consume less space used to be slower since it used to read the entire database to find the changed blocks and also They have difficult time streaming the tape device. .
Considerable improvement has been made in 10g to optimize the algorithm to handle changed block.
Observation :- Introduced in Oracle 8 it has become more powerful and simpler with newer version of Oracle 9 and 10 g. So if you really don't want to miss something critical please start using RMAN.
1. What happens when you run ALTER DATABASE OPEN RESETLOGS ? The current online redo logs are archived, the log sequence number is reset to 1, new database incarnation is created, and the online redo logs are given a new time stamp and SCN.
2. In what scenarios open resetlogs required ?
An ALTER DATABASE OPEN RESETLOGS statement is required after incomplete recovery (Point in Time Recovery) or recovery with a backup control file.
3 . What is SCN (System Change Number) ?
The system change number (SCN) is an ever-increasing value that uniquely identifies a committed version of the database at a point in time. Every time a user commits a transaction Oracle records a new SCN in redo logs.
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. The low SCN records the lowest SCN recorded in the log file while the high SCN records the highest SCN in the log file.
4. What is Database Incarnation ?
Database incarnation is effectively a new “version” of the database that happens when you reset the online redo logs using “alter database open resetlogs;”.
Database incarnation falls into following category Current, Parent, Ancestor and Sibling
i) Current Incarnation : The database incarnation in which the database is currently generating redo.
ii) Parent Incarnation : The database incarnation from which the current incarnation branched following an OPEN RESETLOGS operation.
iii) Ancestor Incarnation : The parent of the parent incarnation is an ancestor incarnation. Any parent of an ancestor incarnation is also an ancestor incarnation.
iv) Sibling Incarnation : Two incarnations that share a common ancestor are sibling incarnations if neither one is an ancestor of the other.
5. How to view incarnation history of Database ?
Using SQL> select * from v$database_incarnation;
Using RMAN>LIST INCARNATION;
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.
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,
RMAN> RESET DATABASE TO INCARNATION 2;
RMAN> RECOVER DATABASE TO SCN 3000;
1.
Give one method for transferring a table from one schema to another?
Answer: There are several possible methods, export-import, CREATE TABLE... AS SELECT, or COPY.
2. What is the purpose of the IMPORT option IGNORE? What is it?s default setting?
Expected Answer: 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.
3. You have a rollback segment in a version 7.2 database that has expanded beyond optimal, how can it be restored to optimal?
Expected answer: Use the ALTER TABLESPACE ..... SHRINK command.
4. If the DEFAULT and TEMPORARY tablespace clauses are left out of a CREATE USER command what happens? Is this bad or good? Why?
Expected answer: The user is assigned the SYSTEM tablespace as a default and temporary tablespace. This is bad because it causes user objects and temporary segments to be placed into the SYSTEM tablespace resulting in fragmentation and improper table placement (only data dictionary objects and the system rollback segment should be in SYSTEM).
5. What are some of the Oracle provided packages that DBAs should be aware of?
Expected answer: Oracle provides a number of packages in the form of the DBMS_ packages owned by the SYS user. The packages used by DBAs may include: DBMS_SHARED_POOL, DBMS_UTILITY, DBMS_SQL, DBMS_DDL, DBMS_SESSION, DBMS_OUTPUT and DBMS_SNAPSHOT. They may also try to answer with the UTL*.SQL or CAT*.SQL series of SQL procedures. These can be viewed as extra credit but aren?t part of the answer.
6. What happens if the constraint name is left out of a constraint clause?
Expected answer: The Oracle system will use the default name of SYS_Cxxxx where xxxx is a system generated number. This is bad since it makes tracking which table the constraint belongs to or what the constraint does harder.
7. What happens if a tablespace clause is left off of a primary key constraint clause?
Expected answer: This results in the index that is automatically generated being placed in then users default tablespace. Since this will usually be the same tablespace as the table is being created in, this can cause serious performance problems.
8. What is the proper method for disabling and re-enabling a primary key constraint?
Expected answer: You use the ALTER TABLE command for both. However, for the enable clause you must specify the USING INDEX and TABLESPACE clause for primary keys.
9. What happens if a primary key constraint is disabled and then enabled without fully specifying the index clause?
Expected answer: The index is created in the user?s default tablespace and all sizing information is lost. Oracle doesn?t store this information as a part of the constraint definition, but only as part of the index definition, when the constraint was disabled the index was dropped and the information is gone.
10. (On UNIX) When should more than one DB writer process be used? How many should be used?
Expected answer: If the UNIX system being used is capable of asynchronous IO then only one is required, if the system is not capable of asynchronous IO then up to twice the number of disks used by Oracle number of DB writers should be specified by use of the db_writers initialization parameter.
11. You are using hot backup without being in archivelog mode, can you recover in the event of a failure? Why or why not?
Expected answer: You can?t use hot backup without being in archivelog mode. So no, you couldn?t recover.
12. What causes the "snapshot too old" error? How can this be prevented or mitigated?
Expected answer: This is caused by large or long running transactions that have either wrapped onto their own rollback space or have had another transaction write on part of their rollback space. This can be prevented or mitigated by breaking the transaction into a set of smaller transactions or increasing the size of the rollback segments and their extents.
13. How can you tell if a database object is invalid?
Expected answer: By checking the status column of the DBA_, ALL_ or USER_OBJECTS views, depending upon whether you own or only have permission on the view or are using a DBA account.
14. A user is getting an ORA-00942 error yet you know you have granted them permission on the table, what else should you check?
Expected answer: You need to check that the user has specified the full name of the object (select empid from scott.emp; instead of select empid from emp;) or has a synonym that points to the object (create synonym emp for scott.emp;)
15. A developer is trying to create a view and the database won?t let him. He has the "DEVELOPER" role which has the "CREATE VIEW" system privilege and SELECT grants on the tables he is using, what is the problem?
Expected answer: You need to verify the developer has direct grants on all tables used in the view. You can?t create a stored object with grants given through views.
16. If you have an example table, what is the best way to get sizing data for the production table implementation?
Answer: The best way is to analyze the table and then use the data provided in the DBA_TABLES view to get the average row length and other pertinent data for the calculation. The quick and dirty way is to look at the number of blocks the table is actually using and ratio the number of rows in the table to its number of blocks against the number of expected rows.
17. How can you find out how many users are currently logged into the database? How can you find their operating system id?
Expected answer: There are several ways. One is to look at the v$session or v$process views. Another way is to check the current_logins parameter in the v$sysstat view. Another if you are on UNIX is to do a "ps -ef|grep oracle|wc -l? command, but this only works against a single instance installation.
18. A user selects from a sequence and gets back two values, his select is:
SELECT pk_seq.nextval FROM dual;
What is the problem?
Expected answer: Somehow two values have been inserted into the dual table. This table is a single row, single column table that should only have one value in it.
19. How can you determine if an index needs to be dropped and rebuilt?
Answer: Run the ANALYZE INDEX command on the index to validate its structure and then calculate the ratio of LF_BLK_LEN/LF_BLK_LEN+BR_BLK_LEN and if it isn?t near 1.0 (i.e. greater than 0.7 or so) then the index should be rebuilt. Or if the ratio
BR_BLK_LEN/ LF_BLK_LEN+BR_BLK_LEN is nearing 0.3.
Answer: There are several possible methods, export-import, CREATE TABLE... AS SELECT, or COPY.
2. What is the purpose of the IMPORT option IGNORE? What is it?s default setting?
Expected Answer: 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.
3. You have a rollback segment in a version 7.2 database that has expanded beyond optimal, how can it be restored to optimal?
Expected answer: Use the ALTER TABLESPACE ..... SHRINK command.
4. If the DEFAULT and TEMPORARY tablespace clauses are left out of a CREATE USER command what happens? Is this bad or good? Why?
Expected answer: The user is assigned the SYSTEM tablespace as a default and temporary tablespace. This is bad because it causes user objects and temporary segments to be placed into the SYSTEM tablespace resulting in fragmentation and improper table placement (only data dictionary objects and the system rollback segment should be in SYSTEM).
5. What are some of the Oracle provided packages that DBAs should be aware of?
Expected answer: Oracle provides a number of packages in the form of the DBMS_ packages owned by the SYS user. The packages used by DBAs may include: DBMS_SHARED_POOL, DBMS_UTILITY, DBMS_SQL, DBMS_DDL, DBMS_SESSION, DBMS_OUTPUT and DBMS_SNAPSHOT. They may also try to answer with the UTL*.SQL or CAT*.SQL series of SQL procedures. These can be viewed as extra credit but aren?t part of the answer.
6. What happens if the constraint name is left out of a constraint clause?
Expected answer: The Oracle system will use the default name of SYS_Cxxxx where xxxx is a system generated number. This is bad since it makes tracking which table the constraint belongs to or what the constraint does harder.
7. What happens if a tablespace clause is left off of a primary key constraint clause?
Expected answer: This results in the index that is automatically generated being placed in then users default tablespace. Since this will usually be the same tablespace as the table is being created in, this can cause serious performance problems.
8. What is the proper method for disabling and re-enabling a primary key constraint?
Expected answer: You use the ALTER TABLE command for both. However, for the enable clause you must specify the USING INDEX and TABLESPACE clause for primary keys.
9. What happens if a primary key constraint is disabled and then enabled without fully specifying the index clause?
Expected answer: The index is created in the user?s default tablespace and all sizing information is lost. Oracle doesn?t store this information as a part of the constraint definition, but only as part of the index definition, when the constraint was disabled the index was dropped and the information is gone.
10. (On UNIX) When should more than one DB writer process be used? How many should be used?
Expected answer: If the UNIX system being used is capable of asynchronous IO then only one is required, if the system is not capable of asynchronous IO then up to twice the number of disks used by Oracle number of DB writers should be specified by use of the db_writers initialization parameter.
11. You are using hot backup without being in archivelog mode, can you recover in the event of a failure? Why or why not?
Expected answer: You can?t use hot backup without being in archivelog mode. So no, you couldn?t recover.
12. What causes the "snapshot too old" error? How can this be prevented or mitigated?
Expected answer: This is caused by large or long running transactions that have either wrapped onto their own rollback space or have had another transaction write on part of their rollback space. This can be prevented or mitigated by breaking the transaction into a set of smaller transactions or increasing the size of the rollback segments and their extents.
13. How can you tell if a database object is invalid?
Expected answer: By checking the status column of the DBA_, ALL_ or USER_OBJECTS views, depending upon whether you own or only have permission on the view or are using a DBA account.
14. A user is getting an ORA-00942 error yet you know you have granted them permission on the table, what else should you check?
Expected answer: You need to check that the user has specified the full name of the object (select empid from scott.emp; instead of select empid from emp;) or has a synonym that points to the object (create synonym emp for scott.emp;)
15. A developer is trying to create a view and the database won?t let him. He has the "DEVELOPER" role which has the "CREATE VIEW" system privilege and SELECT grants on the tables he is using, what is the problem?
Expected answer: You need to verify the developer has direct grants on all tables used in the view. You can?t create a stored object with grants given through views.
16. If you have an example table, what is the best way to get sizing data for the production table implementation?
Answer: The best way is to analyze the table and then use the data provided in the DBA_TABLES view to get the average row length and other pertinent data for the calculation. The quick and dirty way is to look at the number of blocks the table is actually using and ratio the number of rows in the table to its number of blocks against the number of expected rows.
17. How can you find out how many users are currently logged into the database? How can you find their operating system id?
Expected answer: There are several ways. One is to look at the v$session or v$process views. Another way is to check the current_logins parameter in the v$sysstat view. Another if you are on UNIX is to do a "ps -ef|grep oracle|wc -l? command, but this only works against a single instance installation.
18. A user selects from a sequence and gets back two values, his select is:
SELECT pk_seq.nextval FROM dual;
What is the problem?
Expected answer: Somehow two values have been inserted into the dual table. This table is a single row, single column table that should only have one value in it.
19. How can you determine if an index needs to be dropped and rebuilt?
Answer: Run the ANALYZE INDEX command on the index to validate its structure and then calculate the ratio of LF_BLK_LEN/LF_BLK_LEN+BR_BLK_LEN and if it isn?t near 1.0 (i.e. greater than 0.7 or so) then the index should be rebuilt. Or if the ratio
BR_BLK_LEN/ LF_BLK_LEN+BR_BLK_LEN is nearing 0.3.
Tuning Interview Questions
1.
A table-space has a table with 30 extents in it. Is this bad? Why or why not.
Level: Intermediate
Expected answer: Multiple extents in and of themselves aren?t bad. However if you also have chained rows this can hurt performance.
Level: Intermediate
Expected answer: Multiple extents in and of themselves aren?t bad. However if you also have chained rows this can hurt performance.
2. How do
you set up table-spaces during an Oracle installation?
Level: Low
Expected answer: You should always attempt to use the Oracle Flexible Architecture standard or another partitioning scheme to ensure proper separation of SYSTEM, ROLLBACK, REDO LOG, DATA, TEMPORARY and INDEX segments.
Level: Low
Expected answer: You should always attempt to use the Oracle Flexible Architecture standard or another partitioning scheme to ensure proper separation of SYSTEM, ROLLBACK, REDO LOG, DATA, TEMPORARY and INDEX segments.
3. You see
multiple fragments in the SYSTEM table-space, what should you check first?
Level: Low
Expected answer: Ensure that users don?t have the SYSTEM tablespace as their TEMPORARY or DEFAULT tablespace assignment by checking the DBA_USERS view.
Level: Low
Expected answer: Ensure that users don?t have the SYSTEM tablespace as their TEMPORARY or DEFAULT tablespace assignment by checking the DBA_USERS view.
4. What are
some indications that you need to increase the SHARED_POOL_SIZE parameter?
Level: Intermediate
Expected answer: Poor data dictionary or library cache hit ratios, getting error ORA-04031. Another indication is steadily decreasing performance with all other tuning parameters the same.
Level: Intermediate
Expected answer: Poor data dictionary or library cache hit ratios, getting error ORA-04031. Another indication is steadily decreasing performance with all other tuning parameters the same.
5. What is
the general guideline for sizing db_block_size and db_multi_block_read for an
application that does many full table scans?
Level: High
Expected answer: Oracle almost always reads in 64k chunks. The two should have a product equal to 64 or a multiple of 64.
Level: High
Expected answer: Oracle almost always reads in 64k chunks. The two should have a product equal to 64 or a multiple of 64.
6. What is
the fastest query method for a table?
Level: Intermediate
Expected answer: Fetch by rowid
Level: Intermediate
Expected answer: Fetch by rowid
7. Explain
the use of TKPROF? What initialization parameter should be turned on to get
full TKPROF output?
Level: High
Expected answer: The tkprof tool is a tuning tool used to determine cpu and execution times for SQL statements. You use it by first setting timed_statistics to true in the initialization file and then turning on tracing for either the entire database via the sql_trace parameter or for the session using the ALTER SESSION command. Once the trace file is generated you run the tkprof tool against the trace file and then look at the output from the tkprof tool. This can also be used to generate explain plan output.
Level: High
Expected answer: The tkprof tool is a tuning tool used to determine cpu and execution times for SQL statements. You use it by first setting timed_statistics to true in the initialization file and then turning on tracing for either the entire database via the sql_trace parameter or for the session using the ALTER SESSION command. Once the trace file is generated you run the tkprof tool against the trace file and then look at the output from the tkprof tool. This can also be used to generate explain plan output.
8. When
looking at v$sysstat you see that sorts (disk) is high. Is this bad or
good? If
bad -How do you correct it?
Level: Intermediate
Expected answer: If you get excessive disk sorts this is bad. This indicates you need to tune the sort area parameters in the initialization files. The major sort are parameter is the SORT_AREA_SIZe parameter.
Level: Intermediate
Expected answer: If you get excessive disk sorts this is bad. This indicates you need to tune the sort area parameters in the initialization files. The major sort are parameter is the SORT_AREA_SIZe parameter.
9. When
should you increase copy latches? What parameters control copy latches?
Level: high
Expected answer: When you get excessive contention for the copy latches as shown by the "redo copy" latch hit ratio. You can increase copy latches via the initialization parameter LOG_SIMULTANEOUS_COPIES to twice the number of CPUs on your system.
Level: high
Expected answer: When you get excessive contention for the copy latches as shown by the "redo copy" latch hit ratio. You can increase copy latches via the initialization parameter LOG_SIMULTANEOUS_COPIES to twice the number of CPUs on your system.
10. Where
can you get a list of all initialization parameters for your instance? How
about an indication if they are default settings or have been changed?
Level: Low
Expected answer: You can look in the init.ora file for an indication of manually set parameters. For all parameters, their value and whether or not the current value is the default value, look in the v$parameter view.
Level: Low
Expected answer: You can look in the init.ora file for an indication of manually set parameters. For all parameters, their value and whether or not the current value is the default value, look in the v$parameter view.
11.
Describe hit ratio as it pertains to the database buffers. What is the
difference between instantaneous and cumulative hit ratio and which should be
used for tuning?
Level: Intermediate
Expected answer: The hit ratio is a measure of how many times the database was able to read a value from the buffers verses how many times it had to re-read a data value from the disks. A value greater than 80-90% is good, less could indicate problems. If you simply take the ratio of existing parameters this will be a cumulative value since the database started. If you do a comparison between pairs of readings based on some arbitrary time span, this is the instantaneous ratio for that time span. Generally speaking an instantaneous reading gives more valuable data since it will tell you what your instance is doing for the time it was generated over.
Level: Intermediate
Expected answer: The hit ratio is a measure of how many times the database was able to read a value from the buffers verses how many times it had to re-read a data value from the disks. A value greater than 80-90% is good, less could indicate problems. If you simply take the ratio of existing parameters this will be a cumulative value since the database started. If you do a comparison between pairs of readings based on some arbitrary time span, this is the instantaneous ratio for that time span. Generally speaking an instantaneous reading gives more valuable data since it will tell you what your instance is doing for the time it was generated over.
12. Discuss
row chaining, how does it happen? How can you reduce it? How do you correct it?
Level: high
Expected answer: Row chaining occurs when a VARCHAR2 value is updated and the length of the new value is longer than the old value and won?t fit in the remaining block space. This results in the row chaining to another block. It can be reduced by setting the storage parameters on the table to appropriate values. It can be corrected by export and import of the effected table.
Level: high
Expected answer: Row chaining occurs when a VARCHAR2 value is updated and the length of the new value is longer than the old value and won?t fit in the remaining block space. This results in the row chaining to another block. It can be reduced by setting the storage parameters on the table to appropriate values. It can be corrected by export and import of the effected table.
13. When
looking at the estat events report you see that you are getting busy buffer
waits. Is this bad? How can you find what is causing it?
Level: high
Expected answer: Buffer busy waits could indicate contention in redo, rollback or data blocks. You need to check the v$waitstat view to see what areas are causing the problem. The value of the "count" column tells where the problem is, the "class" column tells you with what. UNDO is rollback segments, DATA is data base buffers.
Expected answer: Buffer busy waits could indicate contention in redo, rollback or data blocks. You need to check the v$waitstat view to see what areas are causing the problem. The value of the "count" column tells where the problem is, the "class" column tells you with what. UNDO is rollback segments, DATA is data base buffers.
14. If you
see contention for library caches how can you fix it?
Level: Intermediate
Expected answer: Increase the size of the shared pool.
Level: Intermediate
Expected answer: Increase the size of the shared pool.
15. If you
see statistics that deal with "undo" what are they really talking
about?
Level: Intermediate
Expected answer: Rollback segments and associated structures.
Level: Intermediate
Expected answer: Rollback segments and associated structures.
16. If a
tablespace has a default pctincrease of zero what will this cause (in
relationship to the smon process)?
Level: High
Expected answer: The SMON process won?t automatically coalesce its free space fragments.
Level: High
Expected answer: The SMON process won?t automatically coalesce its free space fragments.
17. If a
tablespace shows excessive fragmentation what are some methods to defragment
the tablespace? (7.1,7.2 and 7.3 only)
Level: High
Expected answer: In Oracle 7.0 to 7.2 The use of the 'alter session set events 'immediate trace name coalesce level ts#';? command is the easiest way to defragment contiguous free space fragmentation. The ts# parameter corresponds to the ts# value found in the ts$ SYS table. In version 7.3 the ?alter tablespace coalesce;? is best. If the free space isn?t contiguous then export, drop and import of the tablespace contents may be the only way to reclaim non-contiguous free space.
Level: High
Expected answer: In Oracle 7.0 to 7.2 The use of the 'alter session set events 'immediate trace name coalesce level ts#';? command is the easiest way to defragment contiguous free space fragmentation. The ts# parameter corresponds to the ts# value found in the ts$ SYS table. In version 7.3 the ?alter tablespace coalesce;? is best. If the free space isn?t contiguous then export, drop and import of the tablespace contents may be the only way to reclaim non-contiguous free space.
18. How can
you tell if a tablespace has excessive fragmentation?
Level: Intermediate
If a select against the dba_free_space table shows that the count of a tablespaces extents is greater than the count of its data files, then it is fragmented.
Level: Intermediate
If a select against the dba_free_space table shows that the count of a tablespaces extents is greater than the count of its data files, then it is fragmented.
19. You see
the following on a status report:
redo log space requests 23
redo log space wait time 0
Is this something to worry about? What if redo log space wait time is high? How can you fix this?
Level: Intermediate
Expected answer: Since the wait time is zero, no. If the wait time was high it might indicate a need for more or larger redo logs.
redo log space requests 23
redo log space wait time 0
Is this something to worry about? What if redo log space wait time is high? How can you fix this?
Level: Intermediate
Expected answer: Since the wait time is zero, no. If the wait time was high it might indicate a need for more or larger redo logs.
20. What
can cause a high value for recursive calls? How can this be fixed?
Level: High
Expected answer: A high value for recursive calls is cause by improper cursor usage, excessive dynamic space management actions, and or excessive statement re-parses. You need to determine the cause and correct it By either relinking applications to hold cursors, use proper space management techniques (proper storage and sizing) or ensure repeat queries are placed in packages for proper reuse.
Level: High
Expected answer: A high value for recursive calls is cause by improper cursor usage, excessive dynamic space management actions, and or excessive statement re-parses. You need to determine the cause and correct it By either relinking applications to hold cursors, use proper space management techniques (proper storage and sizing) or ensure repeat queries are placed in packages for proper reuse.
21. If you
see a pin hit ratio of less than 0.8 in the estat library cache report is this
a problem? If so, how do you fix it?
Level: Intermediate
Expected answer: This indicate that the shared pool may be too small. Increase the shared pool size.
Level: Intermediate
Expected answer: This indicate that the shared pool may be too small. Increase the shared pool size.
22. If you
see the value for reloads is high in the estat library cache report is this a
matter for concern?
Level: Intermediate
Expected answer: Yes, you should strive for zero reloads if possible. If you see excessive reloads then increase the size of the shared pool.
Level: Intermediate
Expected answer: Yes, you should strive for zero reloads if possible. If you see excessive reloads then increase the size of the shared pool.
23. You
look at the dba_rollback_segs view and see that there is a large number of
shrinks and they are of relatively small size, is this a problem? How can it be
fixed if it is a problem?
Level: High
Expected answer: A large number of small shrinks indicates a need to increase the size of the rollback segment extents. Ideally you should have no shrinks or a small number of large shrinks. To fix this just increase the size of the extents and adjust optimal accordingly.
Level: High
Expected answer: A large number of small shrinks indicates a need to increase the size of the rollback segment extents. Ideally you should have no shrinks or a small number of large shrinks. To fix this just increase the size of the extents and adjust optimal accordingly.
24. You
look at the dba_rollback_segs view and see that you have a large number of
wraps is this a problem?
Level: High
Expected answer: A large number of wraps indicates that your extent size for your rollback segments are probably too small. Increase the size of your extents to reduce the number of wraps. You can look at the average transaction size in the same view to get the information on transaction size.
Level: High
Expected answer: A large number of wraps indicates that your extent size for your rollback segments are probably too small. Increase the size of your extents to reduce the number of wraps. You can look at the average transaction size in the same view to get the information on transaction size.
25. In a
system with an average of 40 concurrent users you get the following from a
query on rollback extents:
ROLLBACK CUR EXTENTS
--------------------- --------------------------
R01 11
R02 8
R03 12
R04 9
SYSTEM 4
You have room for each to grow by 20 more extents each. Is there a problem? Should you take any action?
Level: Intermediate
Expected answer: No there is not a problem. You have 40 extents showing and an average of 40 concurrent users. Since there is plenty of room to grow no action is needed.
ROLLBACK CUR EXTENTS
--------------------- --------------------------
R01 11
R02 8
R03 12
R04 9
SYSTEM 4
You have room for each to grow by 20 more extents each. Is there a problem? Should you take any action?
Level: Intermediate
Expected answer: No there is not a problem. You have 40 extents showing and an average of 40 concurrent users. Since there is plenty of room to grow no action is needed.
26. You see
multiple extents in the temporary tablespace. Is this a problem?
Level: Intermediate
Expected answer: As long as they are all the same size this isn?t a problem. In fact, it can even improve performance since Oracle won?t have to create a new extent when a user needs one.
Level: Intermediate
Expected answer: As long as they are all the same size this isn?t a problem. In fact, it can even improve performance since Oracle won?t have to create a new extent when a user needs one.
Installation/Configuration Interview Questions
1.
Define OFA.
Level: Low
Expected answer: OFA stands for Optimal Flexible Architecture. It is a method of placing directories and files in an Oracle system so that you get the maximum flexibility for future tuning and file placement.
Level: Low
Expected answer: OFA stands for Optimal Flexible Architecture. It is a method of placing directories and files in an Oracle system so that you get the maximum flexibility for future tuning and file placement.
2. How do
you set up your tablespace on installation?
Level: Low
Expected answer: The answer here should show an understanding of separation of redo and rollback, data and indexes and isolation os SYSTEM tables from other tables. An example would be to specify that at least 7 disks should be used for an Oracle installation so that you can place SYSTEM tablespace on one, redo logs on two (mirrored redo logs) the TEMPORARY tablespace on another, ROLLBACK tablespace on another and still have two for DATA and INDEXES. They should indicate how they will handle archive logs and exports as well. As long as they have a logical plan for combining or further separation more or less disks can be specified.
Level: Low
Expected answer: The answer here should show an understanding of separation of redo and rollback, data and indexes and isolation os SYSTEM tables from other tables. An example would be to specify that at least 7 disks should be used for an Oracle installation so that you can place SYSTEM tablespace on one, redo logs on two (mirrored redo logs) the TEMPORARY tablespace on another, ROLLBACK tablespace on another and still have two for DATA and INDEXES. They should indicate how they will handle archive logs and exports as well. As long as they have a logical plan for combining or further separation more or less disks can be specified.
3. What
should be done prior to installing Oracle (for the OS and the disks)?
Level: Low
Expected Answer: adjust kernel parameters or OS tuning parameters in accordance with installation guide. Be sure enough contiguous disk space is available.
Level: Low
Expected Answer: adjust kernel parameters or OS tuning parameters in accordance with installation guide. Be sure enough contiguous disk space is available.
4. You have
installed Oracle and you are now setting up the actual instance. You have been
waiting an hour for the initialization script to finish, what should you check
first to determine if there is a problem?
Level: Intermediate to high
Expected Answer: Check to make sure that the archiver isn?t stuck. If archive logging is turned on during install a large number of logs will be created. This can fill up your archive log destination causing Oracle to stop to wait for more space.
Level: Intermediate to high
Expected Answer: Check to make sure that the archiver isn?t stuck. If archive logging is turned on during install a large number of logs will be created. This can fill up your archive log destination causing Oracle to stop to wait for more space.
5. When
configuring SQLNET on the server what files must be set up?
Level: Intermediate
Expected answer: INITIALIZATION file, TNSNAMES.ORA file, SQLNET.ORA file
Level: Intermediate
Expected answer: INITIALIZATION file, TNSNAMES.ORA file, SQLNET.ORA file
6. When
configuring SQLNET on the client what files need to be set up?
Level: Intermediate
Expected answer: SQLNET.ORA, TNSNAMES.ORA
Level: Intermediate
Expected answer: SQLNET.ORA, TNSNAMES.ORA
7. What
must be installed with ODBC on the client in order for it to work with Oracle?
Level: Intermediate
Expected answer: SQLNET and PROTOCOL (for example: TCPIP adapter) layers of the transport programs.
Level: Intermediate
Expected answer: SQLNET and PROTOCOL (for example: TCPIP adapter) layers of the transport programs.
8. You have
just started a new instance with a large SGA on a busy existing server.
Performance is terrible, what should you check for?
Level: Intermediate
Expected answer: The first thing to check with a large SGA is that it isn?t being swapped out.
Level: Intermediate
Expected answer: The first thing to check with a large SGA is that it isn?t being swapped out.
9. What OS
user should be used for the first part of an Oracle installation (on UNIX)?
Level: low
Expected answer: You must use root first.
Level: low
Expected answer: You must use root first.
10. When
should the default values for Oracle initialization parameters be used as is?
Level: Low
Expected answer: Never
Level: Low
Expected answer: Never
11. How
many control files should you have? Where should they be located?
Level: Low
Expected answer: At least 2 on separate disk spindles. Be sure they say on separate disks, not just file systems.
Level: Low
Expected answer: At least 2 on separate disk spindles. Be sure they say on separate disks, not just file systems.
12. How
many redo logs should you have and how should they be configured for maximum
recoverability?
Level:
Intermediate
Expected answer: 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.
Expected answer: 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.
13. You
have a simple application with no "hot" tables (i.e. uniform IO and
access requirements). How many disks should you have assuming standard layout
for SYSTEM, USER, TEMP and ROLLBACK tablespaces?
Expected answer: At least 7, see disk configuration answer above.
Expected answer: At least 7, see disk configuration answer above.
Data Modeler Interview Questions
1.
Describe third normal form?
Level:
Low
Expected answer: Something like: In third normal form all attributes in an entity are related to the primary key and only to the primary key
Expected answer: Something like: In third normal form all attributes in an entity are related to the primary key and only to the primary key
2. Is the
following statement true or false:
"All relational databases must be in third normal form"
Why or why not?
Level: Intermediate
Expected answer: False. While 3NF is good for logical design most databases, if they have more than just a few tables, will not perform well using full 3NF. Usually some entities will be denormalized in the logical to physical transfer process.
"All relational databases must be in third normal form"
Why or why not?
Level: Intermediate
Expected answer: False. While 3NF is good for logical design most databases, if they have more than just a few tables, will not perform well using full 3NF. Usually some entities will be denormalized in the logical to physical transfer process.
3. What is
an ERD?
Level: Low
Expected answer: An ERD is an Entity-Relationship-Diagram. It is used to show the entities and relationships for a database logical model.
Level: Low
Expected answer: An ERD is an Entity-Relationship-Diagram. It is used to show the entities and relationships for a database logical model.
4. Why are
recursive relationships bad? How do you resolve them?
Level: Intermediate
A recursive relationship (one where a table relates to itself) is bad when it is a hard relationship (i.e. neither side is a "may" both are "must") as this can result in it not being possible to put in a top or perhaps a bottom of the table (for example in the EMPLOYEE table you couldn?t put in the PRESIDENT of the company because he has no boss, or the junior janitor because he has no subordinates). These type of relationships are usually resolved by adding a small intersection entity.
Level: Intermediate
A recursive relationship (one where a table relates to itself) is bad when it is a hard relationship (i.e. neither side is a "may" both are "must") as this can result in it not being possible to put in a top or perhaps a bottom of the table (for example in the EMPLOYEE table you couldn?t put in the PRESIDENT of the company because he has no boss, or the junior janitor because he has no subordinates). These type of relationships are usually resolved by adding a small intersection entity.
5. What
does a hard one-to-one relationship mean (one where the relationship on both
ends is "must")?
Level: Low to intermediate
Expected answer: This means the two entities should probably be made into one entity.
Level: Low to intermediate
Expected answer: This means the two entities should probably be made into one entity.
6. How
should a many-to-many relationship be handled?
Level: Intermediate
Expected answer: By adding an intersection entity table
Level: Intermediate
Expected answer: By adding an intersection entity table
7. What is
an artificial (derived) primary key? When should an artificial (or derived)
primary key be used?
Level:
Intermediate
Expected answer: A derived key comes from a sequence. Usually it is used when a concatenated key becomes too cumbersome to use as a foreign key.
Expected answer: A derived key comes from a sequence. Usually it is used when a concatenated key becomes too cumbersome to use as a foreign key.
8. When
should you consider denormalization?
Level: Intermediate
Expected answer: Whenever performance analysis indicates it would be beneficial to do so without compromising data integrity.
1. What are the components of physical database structure of
Oracle database?
Level: Intermediate
Expected answer: Whenever performance analysis indicates it would be beneficial to do so without compromising data integrity.
Oracle Concepts and Architecture Database Structures
1. 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.
2. What are the components of logical database structure of
Oracle database?
There are tablespaces and database's schema objects.
3. What is a tablespace?
A database is divided into Logical Storage Unit called
tablespaces. A tablespace is used to grouped related logical structures
together.
4. 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.
7. 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.
8. Can objects of the same schema reside in different
tablespaces?
Yes.
9. Can a tablespace hold objects from different schemes?
Yes.
10. 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.
11. 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.)
12. Do a view contain data?
Views do not contain or store data.
13. Can a view based on another view?
Yes.
14. 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.
- Hide data complexity.
- Simplify commands for the user.
- Present the data in a different perspective from that of
the base table.
- Store complex queries.
15. What is an Oracle sequence?
A sequence generates a serial list of unique numbers for
numerical columns of a database's tables.
16. What is a
synonym?
A synonym is an alias for a table, view, sequence or program
unit.
17. What are the types of synonyms?
There are two types of synonyms private and public.
18. What is a private synonym?
Only its owner can access a private synonym.
19. What is a public synonym?
Any database user can access a public synonym.
20. 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.
21. 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.
22. How are the index
updates?
Indexes are automatically maintained and used by Oracle.
Changes to table data are automatically incorporated into all relevant indexes.
23. What are clusters?
Clusters are groups of one or more tables physically stores
together to share common columns and are often used together.
24. What is cluster key?
The related columns of the tables in a cluster are called
the cluster key.
25. What is index cluster?
A cluster with an index on the cluster key.
26. 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.
27. When can hash cluster used?
Hash clusters are better choice when a table is often
queried with equality queries. For such queries the specified cluster key value
is hashed. The resulting hash key value points directly to the area on disk
that stores the specified rows.
28. What is database link?
A database link is a named object that describes a
"path" from one database to another.
29. What are the types of database links?
Private database link, public database link & network
database link.
30. 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.
31. 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.
32. 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.
33. 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.
34. 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.
35. 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.
36. 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.
37. What is a
segment?
A segment is a set of extents allocated for a certain
logical structure.
38. What are the different types of segments?
Data segment, index segment, rollback segment and temporary
segment.
39. 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.
40. What is an index segment?
Each index has an index segment that stores all of its data.
41. What is rollback segment?
A database contains one or more rollback segments to
temporarily store "undo" information.
42. What are the uses of rollback segment?
To generate read-consistent database information during
database recovery and to rollback uncommitted transactions by the users.
43. 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.
44. 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 tables and indexes is physically stored in the data
files allocated for a database.
45. 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.
46. What is a redo log?
The set of redo log files for a database is collectively
known as the database redo log.
47. What is the function of redo log?
The primary function of the redo log is to record all
changes made to data.
48. 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.
49. What does a control file contains?
- Database name
- Names and locations of a database's files and redolog
files.
- Time stamp of database creation.
50. 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.
RMAN Interview Questions
1. What is RMAN ?
Recovery Manager (RMAN) is a utility
that can manage your entire Oracle backup and recovery activities.
Which Files must be
backed up?
Database Files (with RMAN)
Control Files (with RMAN)
Offline Redolog Files (with RMAN)
INIT.ORA (manually)
Password Files (manually)
Control Files (with RMAN)
Offline Redolog Files (with RMAN)
INIT.ORA (manually)
Password Files (manually)
2.
When you take a hot backup putting Tablespace in begin backup mode, Oracle
records SCN # from header of a database file. What happens when you issue
hot backup database in RMAN at block level backup? How does RMAN mark the
record that the block has been backed up ? How does RMAN know what blocks
were backed up so that it doesn't have to scan them again?
In 11g, there is Oracle Block
Change Tracking feature. Once enabled; this new
10g feature records the modified since last backup and stores the log of it in
a block change tracking file. During backups RMAN uses the log file to identify
the specific blocks that must be backed up. This improves RMAN's performance as
it does not have to scan whole datafiles to detect changed blocks.
Logging of changed blocks is performed by the CTRW process which is also responsible for writing data to the block change tracking file. RMAN uses SCNs on the block level and the archived redo logs to resolve any inconsistencies in the datafiles from a hot backup. What RMAN does not require is to put the tablespace in BACKUP mode, thus freezing the SCN in the header. Rather, RMAN keeps this information in either your control files or in the RMAN repository (i.e., Recovery Catalog).
Logging of changed blocks is performed by the CTRW process which is also responsible for writing data to the block change tracking file. RMAN uses SCNs on the block level and the archived redo logs to resolve any inconsistencies in the datafiles from a hot backup. What RMAN does not require is to put the tablespace in BACKUP mode, thus freezing the SCN in the header. Rather, RMAN keeps this information in either your control files or in the RMAN repository (i.e., Recovery Catalog).
3. What are the
Architectural components of RMAN?
1.RMAN executable
2.Server processes
3.Channels
4.Target database
5.Recovery catalog database (optional)
6.Media management layer (optional)
7.Backups, backup sets, and backup pieces
2.Server processes
3.Channels
4.Target database
5.Recovery catalog database (optional)
6.Media management layer (optional)
7.Backups, backup sets, and backup pieces
4. What are Channels?
A channel is an RMAN server process started
when there is a need to communicate with an I/O device, such as a disk or a
tape. A channel is what reads and writes RMAN backup files. It is through the
allocation of channels that you govern I/O characteristics such as:
Type
of I/O device being read or written to, either a disk or an sbt_tape
Number
of processes simultaneously accessing an I/O device
Maximum
size of files created on I/O devices
Maximum
rate at which database files are read
Maximum
number of files open at a time
5. Why is the
catalog optional?
Because RMAN manages backup and
recovery operations, it requires a place to store necessary information about
the database. RMAN always stores this information in the target database
control file. You can also store RMAN metadata in a recovery catalog schema
contained in a separate database. The recovery catalog
schema must be stored in a database other than the target database.
schema must be stored in a database other than the target database.
6. What does
complete RMAN backup consist of ?
A backup of all or part of your database. This
results from issuing an RMAN backup command. A backup consists of one or more
backup sets.
7. What is a Backup set? A logical grouping of backup files -- the backup pieces -- that are created when you issue an RMAN backup command. A backup set is RMAN's name for a collection of files associated with a backup. A backup set is composed of one or more backup pieces.
8. What is a Backup piece? A physical binary file created by RMAN during a backup. Backup pieces are written to your backup medium, whether to disk or tape. They contain blocks from the target database's datafiles, archived redo log files, and control files. When RMAN constructs a backup piece from datafiles, there are a several rules that it follows:
7. What is a Backup set? A logical grouping of backup files -- the backup pieces -- that are created when you issue an RMAN backup command. A backup set is RMAN's name for a collection of files associated with a backup. A backup set is composed of one or more backup pieces.
8. What is a Backup piece? A physical binary file created by RMAN during a backup. Backup pieces are written to your backup medium, whether to disk or tape. They contain blocks from the target database's datafiles, archived redo log files, and control files. When RMAN constructs a backup piece from datafiles, there are a several rules that it follows:
·
A datafile cannot span backup sets
·
A datafile can span backup pieces as long as
it stays within one backup set
·
Datafiles and control files can coexist in
the same backup sets
· Archived
redo log files are never in the same backup set as datafiles or control files
RMAN is the only tool that can operate on backup pieces. If you need to restore
a file from an RMAN backup, you must use RMAN to do it. There's no way for you
to manually reconstruct database files from the backup pieces. You must use
RMAN to restore files from a backup piece.
9. What are the
benefits of using RMAN?
1. Incremental backups that only copy data blocks that have
changed since the last backup.
2. Tablespaces are not put in backup mode, thus there is noextra redo log generation during online backups.
3. Detection of corrupt blocks during backups.
4. Parallelization of I/O operations.
5. Automatic logging of all backup and recovery operations.
6. Built-in reporting and listing commands.
2. Tablespaces are not put in backup mode, thus there is noextra redo log generation during online backups.
3. Detection of corrupt blocks during backups.
4. Parallelization of I/O operations.
5. Automatic logging of all backup and recovery operations.
6. Built-in reporting and listing commands.
2.
General Backup and Recovery questions
1. 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
* 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.
2. 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 database 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.
3. 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.
4.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 process 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;
}
5. My database is down and I cannot restore. What now?
This is probably not the appropriate time to be sarcastic,
but, recovery without backups are not supported. You know that you should have
tested your recovery strategy, and that you should always backup a corrupted
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.
6. 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 an 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.
7. 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 parameters 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.
[edit] 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 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.
1. 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.
2.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
database archiving and even database freezes.
3. 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.
4.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:
1. 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 stallically 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
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;
...
2. 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.
3. 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);
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> }
4. 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.
5. 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:
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)';
6. 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.
7. 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.
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>
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
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.
DBA Professional focused
Interview Questions-Answers:
1. 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.
2. 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.
3. How do you switch from an
init.ora file to a spfile?
Issue the create spfile from pfile command.
4. 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.
5. 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.
6. Where would you look for errors from the database
engine?
In the alert log.
7. 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.
8. Give the reasoning behind
using an index.?
Faster access to data blocks in a table.
9. 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.
10. What type of index should you
use on a fact table?
A Bitmap index.
11. Give two examples of
referential integrity constraints.?
A primary key and a foreign key.
12. 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.
13. 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.
14. What command would you use to
create a backup control file?
Alter database backup control file to trace.
15. 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
16. 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.
17. 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
18. 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.
19. Explain 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.
20. 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.
21. How would you determine the
time zone under which a database was operating?
select DBTIMEZONE from dual;
22. Explain the use of setting GLOBAL_NAMES equal to TRUE.
Setting GLOBAL_NAMES dictates how you might connect to a
database. This variable is either TRUE or FALSE and if it is set to TRUE it
enforces database links to have the same name as the remote database to which
they are linking.
23. What command would you use to encrypt a PL/SQL application?
WRAP
24. Explain the difference between a FUNCTION, PROCEDURE and
PACKAGE.?
A function and procedure are the same in that they are
intended to be a collection of PL/SQL code that carries a single task. While a
procedure does not have to return any values to the calling application, a
function will return a single value. A package on the other hand is a
collection of functions and procedures that are grouped together based on their
commonality to a business function or application.
25. Explain the use of table functions.?
Table functions are designed to return a set of rows through
PL/SQL logic but are intended to be used as a normal table or view in a SQL
statement. They are also used to pipeline information in an ETL process.
26. Name three advisory statistics you can collect.?
Buffer Cache Advice, Segment Level Statistics, & Timed
Statistics
27. Where in the Oracle directory tree structure are audit
traces placed?
In unix $ORACLE_HOME/rdbms/audit, in Windows the event viewer
28. Explain materialized views and how they are used.?
Materialized views are objects that are reduced sets of
information that have been summarized, grouped, or aggregated from base tables.
They are typically used in data warehouse or decision support systems.
29. When a user process fails, what background process
cleans up after it?
PMON
30. What background process refreshes materialized views?
The Job Queue Processes.
31. How would you determine what sessions are connected and
what resources they are waiting for?
Use of V$SESSION and V$SESSION_WAIT
32. Describe what redo logs are.?
Redo logs are logical and physical structures that are
designed to hold all the changes made to a database and are intended to aid in
the recovery of a database.
33. How would you force a log switch?
ALTER SYSTEM SWITCH LOGFILE;
34. Give two methods you could use to determine what DDL
changes have been made.?
You could use Logminer or Streams
35. What does coalescing a tablespace do?
Coalescing is only valid for dictionary-managed tablespaces
and de-fragments space by combining neighboring free extents into large single
extents.
36. What is the difference between a TEMPORARY tablespace
and a PERMANENT tablespace?
A temporary tablespace is used for temporary objects such as
sort structures while permanent tablespaces are used to store those objects
meant to be used as the true objects of the database.
37. Name a tablespace automatically created when you create
a database.?
The SYSTEM tablespace.
38. When creating a user, what permissions must you grant to
allow them to connect to the database?
Grant the CONNECT to the user.
39. How do you add a data file to a tablespace?
ALTER TABLESPACE ADD DATAFILE SIZE
40. How do you resize a data file?
ALTER DATABASE DATAFILE RESIZE ;
41. What view would you use to look at the size of a data
file?
DBA_DATA_FILES
42. What view would you use to determine free space in a
tablespace?
DBA_FREE_SPACE
43. How would you determine who has added a row to a table?
Turn on fine grain auditing for the table.
44. How can you rebuild an index?
ALTER INDEX REBUILD;
45. Explain what partitioning is and what its benefit is.?
Partitioning is a method of taking large tables and indexes
and splitting them into smaller, more manageable pieces.
46. You have just compiled a PL/SQL package but got errors,
how would you view the errors?
SHOW ERRORS
47. How can you gather statistics on a table?
The ANALYZE command.
48. How can you enable a trace for a session?
Use the DBMS_SESSION.SET_SQL_TRACE or
Use ALTER SESSION SET SQL_TRACE = TRUE;
49. What is the difference between the SQL*Loader and IMPORT
utilities?
These two Oracle utilities are used for loading data into
the database. The difference is that the import utility relies on the data
being produced by another Oracle utility EXPORT while the SQL*Loader utility
allows data to be loaded that has been produced by other utilities from
different data sources just so long as it conforms to ASCII formatted or
delimited files.
50. Name two files used for network connection to a
database.?
TNSNAMES.ORA and SQLNET.ORA
Data Base Administration
51. What is a database instance? Explain.
A database instance (Server) is a set of memory structure
and background processes that access a set of database files. The processes can
be shared by all of the users.
The memory structure that is used to store the most queried
data from database. This helps up to improve database performance by decreasing
the amount of I/O performed against data file.
52. What is Parallel Server?
Multiple instances accessing the same database (only in
multi-CPU environments)
53. What is a schema?
The set of objects owned by user account is called the
schema.
54. What is an index?
How it is implemented in Oracle database?
An index is a database structure used by the server to have
direct access of a row in a table. An index is automatically created when a
unique of primary key constraint clause is specified in create table command
55. What are clusters?
Group of tables physically stored together because they
share common columns and are often used together is called cluster.
56. What is a cluster key?
The related columns of the tables are called the cluster
key. The cluster key is indexed using a
cluster index and its value is stored only once for multiple tables in the
cluster.
57. What are the basic element of base configuration of an
Oracle database?
It consists of one or
more data files.
one or
more control files.
two or
more redo log files.
The Database contains multiple
users/schemas
one or more
rollback segments
one or
more tablespaces
Data
dictionary tables
User
objects (table,indexes,views etc.,)
The server that access the database consists of
SGA
(Database buffer, Dictionary Cache Buffers, Redo log buffers, Shared SQL pool)
SMON
(System MONito)
PMON
(Process MONitor)
LGWR
(LoG Write)
DBWR (Data
Base Write)
ARCH
(ARCHiver)
CKPT (Check Point)
RECO
Dispatcher
User
Process with associated PGS
58. What is a deadlock? Explain.
Two processes waiting to update the rows of a table, which
are locked by other processes then deadlock arises.
In a database environment this will often happen because of
not issuing the proper row lock commands. Poor design of front-end application
may cause this situation and the performance of server will reduce drastically.
These locks will be released automatically when a
commit/rollback operation performed or any one of this processes being killed
externally.
Memory Management
59. What is SGA?
The System Global Area in an Oracle database is the area in
memory to facilitate the transfer of information between users. It holds the
most recently requested structural information between users. It holds the most
recently requested structural information about the database. The structure is
database buffers, dictionary cache, redo log buffer and shared pool area.
60. What is a shared pool?
The data dictionary cache is stored in an area in SGA called
the shared pool. This will allow sharing of parsed SQL statements among
concurrent users.
61. What is mean by Program Global Area (PGA)?
It is area in memory that is used by a single Oracle user
process.
62. What is a data segment?
Data segment are the physical areas within a database block
in which the data associated with tables and clusters are stored.
63. What are the factors causing the reparsing of SQL
statements in SGA?
Due to insufficient shared pool size.
Monitor the ratio of the reloads takes place while executing
SQL statements. If the ratio is greater than 1 then increase the
SHARED_POOL_SIZE.
Database Logical & Physical Architecture
64. What is Database Buffers?
Database buffers are cache in the SGA used to hold the data
blocks that are read from the data segments in the database such as tables,
indexes and clusters DB_BLOCK_BUFFERS parameter in INIT.ORA decides the size.
65. What is dictionary cache?
Dictionary cache is information about the database objects
stored in a data dictionary table.
66. What is meant by recursive hints?
Number of times processes repeatedly query the dictionary
table is called recursive hints. It is due to the data dictionary cache is too
small. By increasing the SHARED_POOL_SIZE parameter we can optimize the size of
data dictionary cache.
67. What is redo log buffer?
Changes made to the records are written to the on-line redo
log files. So that they can be used in roll forward operations during database
recoveries. Before writing them into the redo log files, they will first
brought to redo log buffers in SGA and LGWR will write into files frequently.
LOG_BUFFER parameter will decide the size.
68. How will you swap objects into a different table space
for an existing database?
Export the user
Perform import using the command imp system/manager
file=export.dmp indexfile=newrite.sql. This will create all definitions into
newfile.sql.
Drop necessary objects.
Run the script newfile.sql after altering the tablespaces.
Import from the backup for the necessary objects.
69. List the Optional Flexible Architecture (OFA) of Oracle
database? How can we organize the
tablespaces in Oracle database to have maximum performance?
SYSTEM - Data dictionary tables.
DATA - Standard
operational tables.
DATA2- Static tables used for standard operations
INDEXES - Indexes for Standard operational tables.
INDEXES1 - Indexes of static tables used for standard
operations.
TOOLS - Tools table.
TOOLS1 - Indexes for tools table.
RBS - Standard Operations Rollback Segments,
RBS1,RBS2 - Additional/Special Rollback segments.
TEMP - Temporary purpose tablespace
TEMP_USER - Temporary tablespace for users.
USERS - User tablespace.
70. How will you force database to use particular rollback
segment?
SET TRANSACTION USE ROLLBACK SEGMENT rbs_name.
71. What is meant by free extent?
A free extent is a collection of continuous free blocks in
tablespace. When a segment is dropped its extents are reallocated and are
marked as free.
72.Which parameter in Storage clause will reduce number of
rows per block?
PCTFREE parameter
Row size also reduces no of rows per block.
73. What is the significance of having storage clause?
We can plan the storage for a table as how much initial
extents are required, how much can be extended next, how much % should leave
free for managing row updating, etc.,
74. How does Space allocation table place within a block?
Each block contains entries as follows
Fixed block header
Variable block header
Row Header, row date (multiple rows may exists)
PCTEREE (% of free space for row updating in future)
75. What is the role of PCTFREE parameter is storage clause?
This is used to reserve certain amount of space in a block
for expansion of rows.
76. What is the OPTIMAL parameter?
It is used to set the optimal length of a rollback segment.
77. What is the functionality of SYSTEM table space?
To manage the database level transactions such as
modifications of the data dictionary table that record information about the
free space usage.
78. How will you create multiple rollback segments in a
database?
Create a database, which implicitly creates a SYSTEM
rollback segment in a SYSTEM tablespace.
Create a second rollback segment name R0 in the SYSTEM
tablespace.
Make new rollback segment available (after shutdown,
modify init.ora file and start database)
Create other tablespaces (RBS) for rollback segments.
Deactivate rollback segment R0 and activate the newly
created rollback segments.
79. How the space utilization takes place within rollback
segments?
It will try to fit the transaction in a cyclic fashion to
all existing extents. Once it found an extent is in use then it forced to
acquire a new extent (number of extents is based on the optimal size)
80. Why query fails sometimes?
Rollback segment dynamically extent to handle larger
transactions entry loads.
A single transaction may wipeout all available free space in
the rollback segment tablespace. This prevents other user using rollback
segments.
81. How will you monitor the space allocation?
By querying DBA_SEGMENT table/view
82. How will you monitor rollback segment status?
Querying the DBA_ROLLBACK_SEGS view
IN USE - Rollback Segment is on-line.
AVAILABLE - Rollback
Segment available but not on-line.
OFF-LINE- Rollback Segment
off-line
INVALID - Rollback Segment
Dropped.
NEEDS RECOVERY - Contains data but need
recovery or corrupted.
PARTLY AVAILABLE -
Contains data from an unresolved transaction involving a distributed database.
83. List the sequence of events when a large transaction
that exceeds beyond its optimal value when an entry wraps and causes the
rollback segment to expand into another extend.?
Transaction Begins.
An entry is made in the RES header for new transactions entry
Transaction acquires blocks in an extent of RBS
The entry attempts to wrap into second extent. None is
available, so that the RBS must extent.
The RBS checks to see if it is part of its OPTIMAL size.
RBS chooses its oldest inactive segment.
Oldest inactive segment is eliminated.
RBS extents
The data dictionary tables for space management are updated.
Transaction Completes.
84. How can we plan storage for very large tables?
Limit the number of extents in the table
Separate table from its indexes.
Allocate sufficient temporary storage.
85. How will you estimate the space required by a
non-clustered tables?
Calculate the total header size
Calculate the available data space per data block
Calculate the combined column lengths of the average row
Calculate the total average row size.
Calculate the average number rows that can fit in a block
Calculate the number of blocks and bytes required for the
table.
After arriving the calculation, add 10 % additional space to
calculate the initial extent size for a working table.
86. It is possible to use raw devices as data files and what
are the advantages over file system files?
Yes.
The advantages over file system files are that I/O will be
improved because Oracle is bye-passing the kernel which writing into disk. Disk
corruption will be very less.
97. What is user
Account in Oracle database?A user account is not a physical structure in database but
it is having important relationship to the objects in the database and will be
having certain privileges.98. How will you enforce security using stored procedures?Don't grant user access directly to tables within the
application.Instead grant the ability to access the procedures that
access the tables.When procedure executed it will execute the privilege of
procedures owner. Users cannot access tables except via the procedure.99. What are the dictionary tables used to monitor a
database space? DBA_FREE_SPACEDBA_SEGMENTSDBA_DATA_FILES.SQL*Plus Statements 100. What are the types of SQL statement? Data Definition Language: CREATE, ALTER, DROP, TRUNCATE,
REVOKE, NO AUDIT & COMMIT. Data Manipulation Language: INSERT, UPDATE, DELETE, LOCK
TABLE, EXPLAIN PLAN & SELECT.Transitional Control: COMMIT & ROLLBACK Session Control: ALTER SESSION & SET ROLESystem Control: ALTER SYSTEM.101. What is a transaction?Transaction is logical unit between two commits and commit
and rollback. 102. What is difference between TRUNCATE & DELETE? TRUNCATE commits after deleting entire table i.e., cannot be
rolled back. Database triggers do not fire on TRUNCATEDELETE allows the filtered deletion. Deleted records can be
rolled back or committed.Database triggers fire on DELETE. 103. What is a join? Explain the different types of joins? Join is a query, which retrieves related columns or rows
from multiple tables.Self Join - Joining the table with itself.Equi Join - Joining two tables by equating two common
columns.Non-Equi Join - Joining two tables by equating two common
columns.Outer Join - Joining two tables in such a way that query can
also retrieve rows that do not have corresponding join value in the other
table.104. What is the sub-query?Sub-query is a query whose return values are used in
filtering conditions of the main query.105. What is correlated sub-query?Correlated sub-query is a sub-query, which has reference to
the main query. 106. Explain CONNECT BY PRIOR?Retrieves rows in hierarchical order eg.select empno, ename from emp where.
Referencing allows you to create objects that inherit their functionality and
appearance from other objects. Referencing an object is similar to copying an
object, except that the resulting reference object maintains a link to its
source object. A reference object automatically inherits any changes that have
been made to the source object when you open or regenerate the module that
contains the reference object.
yes , partially. 1) PROPERTY CLASS - inheritance property 2) OVERLOADING :
procedures and functions.
yes, but you have to use FORMS_DDL.Referencing allows you to create objects that inherit their functionality and
appearance from other objects. Referencing an object is similar to copying an
object, except that the resulting reference object maintains a link to its
source object. A reference object automatically inherits any changes that have
been made to the source object when you open or regenerate the module that
contains the reference object. Any string expression up to 32K: - a literal - an expression or a variable representing the text of a block of dynamically
created PL/SQL code - a DML statement or - a DDL statement Restrictions:The statement you pass to FORMS_DDL may not contain bind variable references in
the string, but the values of bind variables can be concatenated into the
string before passing the result to FORMS_DDL.
Hides characters that the operator types into the text item. This setting is
typically used for password protection.
Yes , in long Raw datatype.
An ALERT is a modal window that displays a message notifying operator of some
application condition.
-NO
When Mouse Navigate is True (the default), Oracle Forms performs standard
navigation to move the focus to the item when the operator activates the item
with the mouse. When Mouse Navigate is set to False, Oracle Forms does not perform navigation
(and the resulting validation) to move to the item when an operator activates
the item with the mouse.
forms run inside the MDI application window. This property is useful for
calling a form from another one.
Yes , object group can have block as well as program units.
It invokes 3GL programs.
Yes . You obtain a return value from a foreign function by assigning the return
value to an Oracle Forms variable or item. Make sure that the Oracle Forms
variable or item is the same data type as the return value from the foreign
function.After assigning an Oracle Forms variable or item value to a PL/SQL variable,
pass the PL/SQL variable as a parameter value in the PL/SQL interface of the
foreign function. The PL/SQL variable that is passed as a parameter must be a
valid PL/SQL data type; it must also be the appropriate parameter type as
defined in the PL/SQL interface.
The entries of Pro * C and user exits and the form which simulate the proc or
user_exit are stored in IAPXTB table in d/b.
YES.
Make sure you include the name of the DLL in the FORMS45_USEREXIT variable of
the ORACLE.INI file, or rename the DLL to F45XTB.DLL. If you rename the DLL to
F45XTB.DLL, replace the existing F45XTB.DLL in the ORAWINBIN directory with the
new F45XTB.DLL.
The dll can be created using the Visual C++ / Visual Basic Tools and then the
dll is put in the path that is defined the registry.
Yes .
Key Mode : Specifies how oracle forms uniquely identifies rows in the
database.This is property includes for application that will run against NON-ORACLE
datasources . Key setting unique (default.) dateable n-updateable.
Identifies a block as transactional control block. i.e. non - database block
that oracle forms should manage as transactional block.(NON-ORACLE datasource)
default - FALSE.
OLE automation allows an OLE server application to expose a set of commands and
functions that can be invoked from an OLE container application. OLE automation
provides a way for an OLE container application to use the features of an OLE
server application to manipulate an OLE object from the OLE container
environment. (FORMS_OLE)
When successive forms are loaded via the CALL_FORM procedure, the resulting
module hierarchy is known as the call form stack.
Yes we can port applications across platforms.Consider the form developed in a
windows system.The form would be generated in unix system by using f45gen
my_form.fmb scott/tiger
Named visual attributes define only font, color, and pattern attributes;
property classes can contain these and any other properties. You can change the appearance of objects at runtime by changing the named
visual attribute programmatically; property class assignment cannot be changed
programmatically. When an object is inheriting from both a property class and a
named visual attribute, the named visual attribute settings take precedence,
and any visual attribute properties in the class are ignored.
When-Mouse-ClickWhen-Mouse-DoubleClickWhen-Mouse-DownWhen-Mouse-EnterWhen-Mouse-LeaveWhen-Mouse-MoveWhen-Mouse-Up
Specifies the named visual attribute used when an item is part of the current
record. Current Record Attribute is frequently used at the block level to
display the current row in a multi-record If you define an item-level Current
Record Attribute, you can display a pre-determined item in a special color when
it is part of the current record, but you cannot dynamically highlight the
current item, as the input focus changes.
Yes. You can programmatically change an object's named visual attribute setting
to change the font, color, and pattern of the object at runtime.
Yes. Change windows registry(regedit). Set form45_font to the desired font. _break
The On-line Redo Log is a set of tow or more on-line redo files that record all
committed changes made to the database. Whenever a transaction is committed,
the corresponding redo entries temporarily stores in redo log buffers of the
SGA are written to an on-line redo log file by the background process LGWR. The
on-line redo log files are used in cyclical fashion.
All the default storage parameters defined for the tablespace can be changed
using the ALTER TABLESPACE command. When objects are created their INITIAL and
MINEXTENS values cannot be changed.
Start an instance, Mount the Database and Open the Database. 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.
No.
Complete database recovery from disk failure is possible only in ARCHIVELOG
mode. Online database backup is possible only in ARCHIVELOG mode.
Close the Database, Dismount the Database and Shutdown the Instance.
Archived Redo Log consists of Redo Log files that have archived before being
reused.
Yes.
Specifies whether the window is a Document window or a Dialog window.
Specifies the event that will activate the OLE containing item.
Yes. Specifies the mouse cursor style. Use this property to dynamically change
the shape of the cursor.
A synonym is an alias for a table, view, sequence or program unit.
A sequence generates a serial list of unique numbers for numerical columns of a
database's tables.
A segment is a set of extents allocated for a certain logical structure.
A schema is collection of database objects of a User.
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.
A Private Synonyms can be accessed only by the owner.
A database link is a named object that describes a "path" from one
database to another.
A cluster with an index on the cluster key.
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.
Hash clusters are better choice when a table is often queried with equality
queries. For such queries the specified cluster key value is hashed. The
resulting hash key value points directly to the area on disk that stores the
specified rows.
Hash clusters are better choice when a table is often queried with equality
queries. For such queries the specified cluster key value is hashed. The
resulting hash key value points directly to the area on disk that stores the
specified rows.
Private database link, public database link & 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.
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.
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.
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.
An extent is a specific number of contiguous data blocks, obtained in a single
allocation and used to store a specific type of information.
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.
Each index has an index segment that stores all of its data.
A database contains one or more rollback segments to temporarily store
"undo" information.
To generate read-consistent database information during database recovery and
to rollback uncommitted transactions by the users.
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.
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 tables and indexes is physically stored in the data files allocated for
a database.
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.
The set of redo log files for a database is collectively known as the database
redo log.
The primary function of the redo log is to record all changes made to data.
Database name- Names and locations of a database's files and redolog files.- Time stamp of database creation.
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Issue the create spfile from pfile command.
In the alert log.
A Bitmap index.
Disable the foreign key constraint to the parent, drop the table, re-create the
table, enable the foreign key constraint.
Create a plan table with utlxplan.sql.Use the explain plan set statement_id = 'tst1' into plan_table for a SQL
statementLook at the explain plan with utlxplp.sql or utlxpls.sql
WRAP
Use of V$SESSION and V$SESSION_WAIT
ALTER SYSTEM SWITCH LOGFILE;
A temporary tablespace is used for temporary objects such as sort structures
while permanent tablespaces are used to store those objects meant to be used as
the true objects of the database.
Grant the CONNECT to the user.
DBA_DATA_FILES
ALTER INDEX <index_name> REBUILD;
The ANALYZE command.
These two Oracle utilities are used for loading data into the database. The
difference is that the import utility relies on the data being produced by
another Oracle utility EXPORT while the SQL*Loader utility allows data to be
loaded that has been produced by other utilities from different data sources
just so long as it conforms to ASCII formatted or delimited files.
No, this is listed as Enhancement Request 148742. Workaround: Export all of the objects from the tablespaceDrop the tablespace including contentsRecreate the tablespaceImport the objects
Choosing an executing planbased on the access paths available and the ranks of
these access paths.
While your production database is running, take an (image copy) backup and
restore it on duplicate hardware. Note that an export will not work!!! On your standby database, issue the following commands: ALTER DATABASE CREATE STANDBY CONTROLFILE AS 'filename';ALTER DATABASE MOUNT STANDBY DATABASE;RECOVER STANDBY DATABASE;On systems prior to Oracle 8i, write a job to copy archived redo log files from
the primary database to the standby system, and apply the redo log files to the
standby database (pipe it). Remember the database is recovering and will prompt
you for the next log file to apply. Oracle 8i onwards provide an "Automated Standby Database" feature,
which will send archived, log files to the remote site via NET8, and apply then
to the standby database. When one needs to activate the standby database, stop the recovery process and
activate it: ALTER DATABASE ACTIVATE STANDBY DATABASE;
Each server and background process can write an associated trace file. When an
internal error is detected by a process or user process, it dumps information
about the error to its trace. This can be used for tuning the database.
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 an restored export file. 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.
Run_product is a built-in, Used to invoke one of the supported oracle tools
products and specifies the name of the document or module to be run. If the
called product is unavailable at the time of the call, Oracle Forms returns a
message to the operator.
Report 2.5 is object oriented.
A user named editor can be displayed programmatically with the built in
procedure SHOW-EDITOR, EDIT_TETITEM independent of any particular text item.
A record group can have an unlimited number of columns of type CHAR, LONG,
NUMBER, or DATE provided that the total number of column does not exceed 64K.
A query record group is a record group that has an associated SELECT statement.
The columns in a query record group derive their default names, data types, had
lengths from the database columns referenced in the SELECT statement. The
records in query record group are the rows retrieved by the query associated
with that record group.
What are the various sub events a mouse double
click event involves?
An anchoring object is a print condition object which used to explicitly or
implicitly anchor other objects to itself.
Double clicking the mouse consists of the mouse down, mouse up, mouse click,
mouse down & mouse up events.
What are the various sub events a mouse double click event
involves?
The following high-level tuning indicators can be used to establish if a
database is performing optimally or not: . Buffer Cache Hit RatioFormula: Hit Ratio = (Logical Reads - Physical Reads) / Logical ReadsAction: Increase DB_CACHE_SIZE (DB_BLOCK_BUFFERS prior to 9i) to increase hit
ratio . Library Cache Hit RatioAction: Increase the SHARED_POOL_SIZE to increase hit ratio
Erase removes an indicated global variable.
Break.SYSTEM VARIABLES
It is area in memory that is used by a Single Oracle User Process.
Oracle user accounts can be locked, unlocked, forced to choose new passwords,
etc. For example, all accounts except SYS and SYSTEM will be locked after
creating an Oracle9iDB database using the DB Configuration Assistant (dbca).
DBA's must unlock these accounts to make them available to users. Look at these examples: ALTER USER scott ACCOUNT LOCK -- lock a user accountALTER USER scott ACCOUNT UNLOCK; -- unlocks a locked users accountALTER USER scott PASSWORD EXPIRE; -- Force user to choose a new password
Objects of different modules Another object groupsIndividual block dependent items Program units.
SQLCODE returns the latest code of the error that has occurred.SQLERRM returns the relevant error message of the SQLCODE.
Some scalar data types such as NUMBER, VARCHAR2, DATE, CHAR, LONG, BOOLEAN.
Some composite data types such as RECORD & TABLE.
PL/SQL uses block structure as its basic structure. Anonymous blocks or nested
blocks can be used in PL/SQL
Objects of type TABLE are called "PL/SQL tables", which are modeled
as (but not the same as) database tables, PL/SQL tables use a primary PL/SQL
tables can have one column and a primary key. Cursors
No comments:
Post a Comment