Professional Documents
Culture Documents
5 Networking 22
6 Backup/Recovery 23-27
NK-8125652330
Oracle 11g Architecture Question's
1) What is a database?
• Database offer a single point of mechanism for storing and retrieving information with the help of
tables.
• Table is made up of columns and rows where each column stores specific attribute and each row
displays a value for the corresponding attribute.
• It is a structure that stores information about the attributes of the entities and relationships among
them.
• It also stores data types for attributes and indexes.
• Well known DBMS include Oracle, ibm db2, Microsoft sql server, Microsoft access, mysql and
sqlLite.
2) What are the different types of storage systems available and which one is used by Oracle?
• Most databases use RDBMS model, Oracle also uses RDBMS model.
4) What are the components of logical data model and list some differences between logical and
physical data model?
• Logical data model represents database in terms of logical objects, such as entities and
relationships.
NK-8125652330
• Physical data model represents database in terms of physical objects, such as tables and
constraints.
• Normalization is a process of organizing the fields and tables of a relational database to minimize
redundancy and dependency.
• It saves storage space and ensures consistency of our data.
• First Normal Form – If all underlying domains contain atomic values only.
• Second Normal Form – If it is in first normal form and every non key attribute is fully functionally
dependent on primary key.
• Third Normal Form - If it is in 2nd normal form and every non key attribute is non transitively
dependent on the primary key.
• Boyce Codd Normal Form - A relation R is in BCNF if and only every determinant is a candidate
key.
6) Differentiate between a database and Instance and explain relation between them?
• Database is a collection of three important files which include data files, control files and redo log
files which physically exist on a disk
• Whereas instance is a combination of oracle background process (SMON, PMON, DBWR, LGWR) and
memory structure (SGA, PGA).
• Oracle background processes running on a computer share same memory area.
• An instance can mount and open only a single database, ever.
• A database may be mounted and opened by one or more instances (using RAC).
• SGA (System Global Area) is a memory area allocated during an instance start up.
• SGA is allocated as 40% of RAM size by default.
• SGA size is controlled by DB_CACHE_SIZE parameter defined in initialization parameter file
(init.ora file or SPFILE).
• PGA (Program or Process Global Area) is a memory area that stores a user session specific
NK-8125652330
information.
These are the physical components which gets stored in the disk.
• Data files
• Redo Log files
• Control files
• Password files
• Parameter files
11) What is Database Writer (DBWR) and when does DBWR write to the data file?
• DBWR is a background process that writes data blocks information from Database buffer cache to
data files.
There are 4 important situations when DBWR writes to data file
• Every 3 seconds
• Whenever checkpoint occurs
• When server process needs free space in database buffer cache to read new blocks.
• Whenever number of changed blocks reaches a maximum value.
12) What is Log Writer and when does LGWR writes to log file?
• LGWR writes redo or changed information from redo log buffer cache to redo log files in database.
• It is responsible for moving redo buffer information to online redo log files, when you commit and a
log switch also occurs.
• LGWR writes to redo files when the redo log buffer is 1/3 rd full.
• It also writes for every 3 seconds.
• Before DBWR writes modified blocks to the datafiles, LGWR writes to the
log file
13) Which Table spaces are created automatically when you create a database?
NK-8125652330
14) Which file is accessed first when Oracle database is started and What is the difference between
SPFILE and PFILE?
• SPFILE is by default created during database creation whereas PFILE should be created from
SPFILE.
• PFILE is client side text file whereas SPFILE is server side binary file.
• SPFILE is a binary file (it can’t be opened) whereas PFILE is a text file we can edit it and set
parameter values.
• Changes made in SPFILE are dynamically effected with running database whereas PFILE changes
are effected after bouncing the database.
• We can backup SPFILE using RMAN.
16) How can you find out if the database is using PFILE or SPFILE?
• You can query Dynamic performance view (v$parameter) to know your database is using PFILE or
SPFILE.
17) Where are parameter files stored and how can you start a database using a specific parameter
file?
• In UNIX they are stored in the location $ORACLE_HOME/dbs and ORACLE_HOME/database for
Windows directory.
• You can create PFILE from SPFILE as create PFILE from SPFILE;
• All the parameter values are now updated with SPFILE.
• Similarly, create SPFILE from PFILE; command creates SPFILE from PFILE.
NK-8125652330
• PGA_AGGREGATE TARGET parameter specifies target aggregate PGA memory available to all
server process attached to an instance.
• Oracle sets its value to 20% of SGA.
• It is used to set overall size of work-area required by various components.
• Its value can be known by querying v$pgastat dynamic performance view.
• From sqlplus it can be known by using SQL> show parameter pga.
19) What is the purpose of configuring more than one Database Writer Processes? How many should
be used? (On UNIX)
• DBWn process writes modified buffers in Database Buffer Cache to data files, so that user process
can always find free buffers.
• To efficiently free the buffer cache to make it available to user processes, you can use multiple
DBWn processes.
• We can configure additional processes (DBW1 through DBW9 and DBWa through DBWj) to improve
write performance if our system modifies data heavily.
• If the Unix system being used is capable of asynchronous input/output processing then only one
DBWn process is enough, if not the case the total DBWn processes required will be twice the number
of disks used by oracle, and this can be set with DB_WRITER_PROCESSES initialization parameter.
20) List out the major installation steps of oracle software on UNIX in brief?
• Set up disk and make sure you have Installation file (run Installer) in your dump.
• Check the swap and TEMP space .
• Export the following environment variables
1) ORACLE_BASE
2) ORACLE_HOME
3) PATH
4) LD_LIBRARY_PATH
5) TNS_ADMIN
21) Can we check number of instances running on Oracle server and how to set kernel parameters in
Linux?
• Editing the /etc/oratab file on a server gives the list of oracle instances running on your server.
• Editing /etc/sysctl.conf file with vi editor will open a text file listing out kernel level parameters.
• We can make changes to kernel parameters as required for our environment only as a root user.
• To make the changes affected permanently to kernel run the command /sbin/sysctl –p.
• We must also set file maximum descriptors during oracle installation which can be done by
editing /etc/security/limits.conf as a root user.
NK-8125652330
22) What is System Activity Reporter (SAR) and SHMMAX?
• ORACLE_BASE=/u01/app/<installation-directory>
• ORACLE_HOME=$ORACLE_BASE/product/11.2.0(for 11g)/dbhome_1
• ORACLE_SID=<instance-name>
• PATH=$ORACLE_HOME/bin:$PATH
• LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
• TNS_ADMIN=$ORACLE_HOME/network/admin
• These are absolutely critical environment variables in running OUI.
• Control file is a binary file which records the physical structure of a database.
• It includes number of log files and their respective location, Database name and timestamp when
database is created, checkpoint information.
• We find CONTROL_FILE parameter in initialization parameter file which stores information about
control file location.
• We can multiplex control files, store in different locations to make control files available even if one
is corrupted.
• We can also avoid the risk of single point of failure.
25) At what stage of instance, control file information is read and can we recover control file and how
to know information in a control file?
NK-8125652330
27) How do you resize a data file and tablespace?
28) Name the views used to look at the size of a datafile, controlfiles, block size, determine free
space in a tablespace ?
• In archive log mode, the database will makes archive of all redo log files that are filled, called as
archived redo logs or archive log files.
• By default your database runs in NO ARCHIVE LOG mode, so we can’t perform online backup’s
(HOT backup).
• You must shut down database to perform clean backup (COLD backup) and recovery can be done
to the previous backup state.
• Archive log files are stored in a default location called FRA (Flash Recovery Area).
• We can also define our own backup location by setting log_archive_dest parameter.
30) Assume you work in an xyz company as senior DBA and on your absence your back up DBA has
corrupted all the control files while working with the ALTER DATABASE BACKUP CONTROLFILE
command. What do you do?
• As long as all data files are safe and on a successful completion of BACKUP control file command by
your Back up DBA you are in safe zone.
• We can restore the control file by performing following commands
1) CONNECT INTERNAL STARTUP MOUNT
2) TAKE ANY OFFLINE TABLESPACE (Read-only)
3) ALTER DATABASE DATAFILE (OFFLINE)
4) RECOVER DATABASE USING BACKUP CONTROL FILE
5) ALTER DATABASE OPEN RESETLOGS
6) BRING READ ONLY TABLE SPACE BACK ONLINE
• Then give the command ALTER DATABSE BACKUP CONTROL FILE TO TRACE
NK-8125652330
If control file backup is not available, then the following will be required
• In oracle 11g you reduce space of TEMP datafile by shrinking the TEMP tablespace.It is a new
feature to 11g.
• The dynamic performance view can be very useful in determining which table space to shrink.
32) What do you mean by database backup and which files must be backed up?
• Database stores most crucial data of business ,so it’s important to keep the data safe and this can
be achieved by backup.
• The following files must be backed up
33) What is a full backup and name some tools you use for full backup?
• A full backup is a backup of all the control files, data files, and parameter file (SPFILE or PFILE).
• You must also backup your ORACLE_HOME binaries which are used for cloning.
• A full backup can be performed when our database runs in NON ARCHIVE LOG mode.
• As a thumb rule, you must shutdown your database before you perform full backup.
• Full or COLD backup can be performed by using copy command in unix.
34) What are the different types of backup’s available and also explain the difference between them?
• Hot backup is taken when the database is still online and database should be in ARCHIVE LOG
MODE.
• Cold backup is taken when the database is in offline mode.
• Hot backup is inconsistent backup where as cold backup is consistent backup.
• You can begin backup by using the following command
NK-8125652330
SQL> alter database begin backup;
• End backup by
SQL> alter database end backup;
35) How to recover database if we lost the control file and we do not have a backup and what is
RMAN?
• We can recover our database at any point of time, when we have backup of our control files in
different mount points.
• Also check whether the control file is available in trace file located in USERDUMP or the alert log to
recover the database.
RMAN
• RMAN called as Recovery manager tool supplied by oracle that can be used to manage backup and
recovery activities.
• You can perform both offline (Cold) and online (Hot) backup’s using RMAN.
• We need to configure Flash_Recovery_Area of database to use RMAN.
• RMAN maintains the repository of backup information in control file.
• RMAN executable
• Server process
• Channels
• Target database
• Recovery catalog database
• Media management layer
• Backup sets and backup pieces
• Table spaces are not put in the backup mode ,therefore there is no extra redo log file during online
backups.
• Incremental backups that only copy data blocks, which have changed since last backup.
• Detection of corrupt blocks.
• Built in reporting and listing commands.
• Parallelization of I/O operations.
39) How to bring a database from ARCHIVE LOG mode to NON ARCHIVE LOG MODE?
NK-8125652330
• You should change your init<SID>.ora file with the following information
• log_archive_dest=’/u01/oradata/archlog’ (for example)
• log_archive_format=’%t_%s.dbf’
• log_archive_start=true (prior to 10g)
• sql>shutdown;
• sql> startup mount;
• sql> alter database archivelog;
• sql>alter database open;
• Make sure you backup your database before switching to ARCHIVELOG mode.
• Database undergoes different stages before making itself available to end users
• Following stages are involved in the startup of database
? NoMount
? Mount
? Open
41) Name some of the important dynamic performance views used in Oracle.
• V$Parameter
• V$Database
• V$Instance
• V$Datafiles
• V$controlfiles
• V$logfiles
42) What are the different methods we can shutdown our database?
It’s just like an immediate power off for a database, it doesn’t mind what are the transactions
running it just stops entire activity -(even committed transactions are not reflected in database) and
make database unavailable. SMON process takes responsibility for recovery during next startup of
database.
NK-8125652330
43) What are the different types of indexes available in Oracle?
44) What is the use of ALERT log file? Where can you find the ALERT log file?
• Alert log file is a log file that records database-wide events which is used for trouble shooting.
• We can find the Log file in BACKGROUND_DUMP_DEST parameter.
• Following events are recorded in ALERT log file:
• Database shutdown and startup information.
• All non-default parameters.
• Oracle internal (ORA-600) errors.
• Information about a modified control file.
• Log switch change.
NK-8125652330
• Latch is an on/off switch in oracle that a process must access in order to perform certain type of
activities.
• They enforce serial access to the resources and limit the amount of time for which a single process
can use a resource.
• A latch is acquired for a very short amount of time to ensure that the resource is allocated.
• We may face performance issues which may be due to either of the two following reasons
• Lack of availability of resource.
• Poor application programming resulting in high number of requests for resource.
• Latch information is available in the v$LATCH and v$LATCHHOLDER dynamic performance views.
NK-8125652330
Controlfile and Redolog File Management
1. What is Archived Redo Log?
Archived Redo Log consists of Redo Log files that have archived before being reused.
5. What happens when archive log destination becomes 100% full when the database is running in
ARCHIVELOG mode? How do you recover? The database gets shutdown. We should move old
archives to different location and startup the database.
7. What is a stale?
The redolog file which has not been used yet
11. If you want to maintain one more archive destination which parameter you have to set?
It’s a dynamic parameter you have to set log_archive_dest_1=
NK-8125652330
14. What is the parameter allows you to create max no. of groups?
In controlfile recreation script , maxlogfiles=
NK-8125652330
Database Creation and Tablespace Management
2. What are the steps involved in Database Shutdown? Close the Database; Dismount the Database
and Shutdown the Instance.
5. While creating database can you specify the size of control files?
No
7. After mounting a database using command STARTP MOUNT can you open your database in
RESTRICTED MODE. Using command “alter database open restrict;”
No.
8. While creating database can you specify more than one datafile for SYSTEM Tablespace?
Yes
10. 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
toORACLE 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
11. How do you get the create syntax of a table or index or function or procedure? Select
dbms_metadata.get_ddl('TABLE','EMP','SCOTT') from dual;
12. Explain about System Table space and sysaux tablespace? System table space has all the view
relating to oracle. Sysaux tablespace is used for storage of non-system related tables and indexes
NK-8125652330
that traditionally were placed in the System Tablespace. Like RMAN recovery catalog, Automatic
workload repository and ultra search.
13. What are the different modes of mounting a Database with the Parallel Server?Exclusive Mode If
the first instance that mounts a database does so in exclusive mode, only that Instance can mount
the database. Parallel Mode If the first instance that mounts a database is started in parallel mode,
other instances that are started in parallel mode can also mount the database.
14. Where alert log is stored? What is the parameter?
In trace directory /disk2/oradata/prod/diag/rdbms/prod/prod/trace).parameter is diagnostic_dest
(oracle 11g)
16. How many redo logs should you have and how should they be configured for maximum
recoverability? You should have at least three groups of two redo logs with the two logs each on a
separate disk spindle (mirrored by Oracle).
1. What is a Tablespace?
A database is divided into Logical Storage Unit called tablespaces.A tablespace is used to grouped
related logical structures together
NK-8125652330
Linux> cp oldname to newname
-Change the datafile name;
Sys>> Alter tablepsace <TBSNAME> rename datafile 'oldname' to 'newname';
9. Explain the relationship among Database, Tablespace and Data file? Each databases logically
divided into one or more tablespaces one or more data files are explicitly created for each tablespace
10. How do you drop a tablespace? Drop tablespace ts1 including contents and datafiles;
NK-8125652330
User Management and Undo Management
3. Is CONNECT a system privilege or a role? If the answer is 'a role', what system privileges are
assigned to this role by default?
It is a role .create session.
7. Can a segment (table) present on more than one tablespace? No, Possible only when a table if
create by using partition feature.
16. Define Transaction? A Transaction is a logical unit of work that comprises one or more SQL
statements executed by a single user.
17. What is default tablespace? The Tablespace to contain schema objects created without specifying
a tablespace name.
18. What is Tablespace Quota? The collective amount of disk space available to the objects in a
schema on a particular tablespace.
19. What is the use of Roles? REDUCED GRANTING OF PRIVILEGES - Rather than explicitly granting
the same set of privileges to many users a database administrator can grant the privileges for a
group of related users granted to a role and then grant only the role to each member of the group.
NK-8125652330
DYNAMIC PRIVILEGE MANAGEMENT - When the privileges of a group must change, only the
privileges of the role need to be modified. The security domains of all users granted the group's role
automatically reflect the changes made to the role.
SELECTIVE AVAILABILITY OF PRIVILEGES - The roles granted to a user can be selectively enable
(available for use) or disabled (not available for use). This allows specific control of a user's
privileges in any given situation.
APPLICATION AWARENESS - A database application can be designed to automatically enable and
disable selective roles when a user attempts to use the application.
20. What is a profile?Each database user is assigned a Profile that specifies limitations on various
system resources available to the user.
21. What are the roles and user accounts created automatically with the database?20 roles are
created, 7 user accounts are created when database is created manually
22. 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.
24. What are roles? How can we implement roles?Roles are the easiest way to grant and manage
common privileges needed by different groups of database users. Creating roles and assigning
provides to roles. Assign each role to group of users. This will simplify the job of assigning privileges
to individual users.
25. What does ROLLBACK do?ROLLBACK retracts any of the changes resulting from the SQL
statements in the transaction.
26. What is a deadlock? Explain.Two processes waiting to update the same rows of a table which are
locked by the other process then deadlock arises. In a database environment this will often happen
because of not issuing 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 these processes being
killed externally
27. How do you get you demo files get created in your user?
$ORACLE_HOME/rdbms/admin/utlsampl.sql, edit and execute this script
1. Tell me about ORA 1555 and how do you address if you get this error?
It usually occurs after queries or batch processes have been running for a long time, which means
you can lose many hours of processing when the error crops up.There are three situations that can
cause the ORA-01555 error:
NK-8125652330
A. An active database with an insufficient number of small-sized rollback segments
B.A rollback segment corruption that prevents a consistent read requested by the query
C.A fetch across commits while your cursor is open
3. What is the view to see UNDO for how much data flushed out and how much data it having
now….how many active blocks, expired blocks?
V$undostat
4. Two users fired a same statement at same time. performance degrades or good. What happens if
it is select statement and for insert statement?
Performance comes down….there is chance for getting 1555 error.
5. What does ROLLBACK do? ROLLBACK retracts any of the changes resulting from the SQL
statements in the transaction.
6. What are the init parameters you have to set to make use of undo management?
undo_tablespace= undotbs1
undo_management= auto
undo_retention= time in minutes
comment rollback_segment
7. What is Rollback Segment?A Database contains one or more Rollback Segments to temporarily
store "undo" information.
8. Can flashback work on database with out undo and with rollback segments?
No.
NK-8125652330
Networking
1. What background process refreshes materialized views? Cjqo (co-ordinate job queue)
2. What is the default location for tnsnames.ora and sqlnet.ora files and if you don't find them there,
where do you look? $ORACLE_HOME/network/admin/samples
7. What is the password you have to set in the init.ora to enable remote
login remote_login_password_file=exclusive
8. How do you connect to db and startup and shutdown the db without having dba group?Using
remote_login_passwordfile
13. What is a runaway session?You killed a session in the database but it still remains in the os level
and vice versa. Its called runaway session. If runaway session is there CPU consumes more usage.
14. What is netstat? And it’s Usage? It is a utility to know the port numbers availability. Usage:
netstat -na grep port number
NK-8125652330
Backup/Recovery
2. A database is running in NOARCHIVELOG mode then which type of backups you can take?
Offline/Cold/Consistent Backup
3. Can you take partial backups if the Database is running in NOARCHIVELOG mode?
No, Partial backup cannot take while database is not in archive log mode.
Partial backup will not be synchronized with the rest of the database. It is a copy of just part of the
database, at a particular moment in time. If it is ever necessary to restore a file from partial backup ,
it will have to resynchronized with the rest of the database with the help of archivelog. Means
applying the changes from the archived and online redo log files to bring it up to date.
So, there is no concept of partial backup, if our database is not running in archive log mode.
4. Can you take Online Backups if the database is running in NOARCHIVELOG mode?
No, we can’t take online backup while database is running in no archive log mode.A datafile that is
backed up online will not be synchronized with any particular SCN, nor it will be synchronized with
other data fileor the control files. Archive log applying is mandatory to resynchrinize the backed up
datafile with SCN and other datafiles or control file.
5. How do you bring the database in ARCHIVELOG mode from NOARCHIVELOG mode?
Note: To put the database from no archive to archive, database must be in mount mode( No mount
or open mode will not allow to put the database in archive log mode). Similary to put the database in
no archivelog mode from archive, the same rule will be applicable (No mount or open mode will not
allow to put the database in archive log mode).
Archive to No Archive log mode
Sql> select log_mode from v$database;
LOG_MODE
------------
ARCHIVELOG
Sql> shut down immediate;
Sql> startup mount;
sql> alter database noarchivelog;
sql> select log_mode from v$database;
NK-8125652330
LOG_MODE
------------
NOARCHIVELOGNo Archive log mode to archive log mode
Sql> select log_mode from v$database;
LOG_MODE
------------
NOARCHIVELOG
SQL> archive log list;
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 14
Current log sequence 17
SQL> shutdown immediate;
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
LOG_MODE
------------
NOARCHIVELOG
SQL> alter database archivelog;
Database altered.
SQL> select log_mode from v$database;
LOG_MODE
------------
ARCHIVELOG
SQL> select log_mode from v$database;
LOG_MODE
------------
ARCHIVELOG
NK-8125652330
6. You cannot shutdown the database for even some minutes, then in which mode you should run
the database?
Database must be running in Archive log mode.
Differences concerning backups
No archive log
Archive log
Must backup entire database.
Can backup parts of database (datafiles tablespaces)
DB must be shut down.
hot backups possible
Only entire DB can be restored
Tablespaces can be restored
In case of a failure, all changes sinces the last backup will be lost
All commited transactions will be restorable
7. Where should you place Archive logfiles, in the same disk where DB is or another disk?For the
database performance reason and disk failure , we should store the archive log file at another disk .
10. Should you take the backup of Logfiles if the database is running in ARCHIVELOG mode?
No, there is no need to take the backup of online redo log file while our database is running in no
archivelog mode, why because whatever information is containg by redo log jhas already been
moved to archived redo log file before switching to next redo. So there is no benefit to take up the
backup of online redo log files.
NK-8125652330
11. Why do you take tablespaces in Backup mode?
The goal of ALTER TABLESPACE BEGIN BACKUP and END BACKUP is to set special actions in the
current database files in order to make their copy usable , without affecting the current operations.
Nothing needs to be changed in the current datafile , but, as the copying is done by the external
tool( Operating system utility), the only way to have something set in the copy is to do it in the
current datafiles before the copy , and revert it back at the end.
Sql> alter tablespace begin backup;
While putting the tablespace in backup mode,
-the hot backup falg in the datafile header is set , so that the copy is identified to be a hot backup
copy. This is to manage the backup consistency issue when the copy will be used for recovery.
- Checkpoint is done for the tablespace, so that in case of recovery , no redo generated before that
point will be applied. Begin backup command completes only when checkpoint is done.
13. What are the advantages of operating a database in ARCHIVELOG mode over operating it in
NO ARCHIVELOG mode?
Complete database recovery from disk failure is possible only in ARCHIVELOG mode. Online database
backup is possible only in ARCHIVELOG mode.
14. How do you restore and recover a datafile while the database is up and running?
Make the datafile offline, restore and recover datafile, make the datafile online;
18. How do you know whether the specific tablespace is in begin backup mode?
Select status from v$backup. if it is active it means it is in begin backup mode
21. How do you applying archive logs to cold backup of previous day?
Steps involved in recovery are:
- restore cold backup
- Startup mount
-recover database using backup control file until cancel
NK-8125652330
-alter database open resetlogs
-shutdown
-startup
24. What is Partial Backup? A Partial Backup is any operating system backup short of a full backup,
taken while the database is open or shut down.
25. 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.
26. 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.
NK-8125652330
Log Miner SQL Loader Auditing
NK-8125652330
Using the Online Catalog: Oracle recommends that you use this option when you will have access to
the source database from which the redo log files were created and when no changes to the column
definitions in the tables of interest are anticipated. This is the most efficient and easy-to-use option.
Extracting a Log Miner Dictionary to the Redo Log Files: Oracle recommends that you use this option
when you do not expect to have access to the source database from which the redo log files were
created, or if you anticipate that changes will be made to the column definitions in the tables of
interest.
Extracting the LogMiner Dictionary to a Flat File:This option is maintained for backward compatibility
with previous releases. This option does not guarantee transactional
consistency. Oracle recommends that you use either the online catalog or extract the dictionary from
redo log files instead.
1. What is Auditing?
Monitoring of user access to aid in the investigation of database use.
2. What is the default destination where Oracle creates audit trail files automatically when you login
as a sysdba?
$ORACLE_HOME/rdbms/audit
3. A table deleted by a user, how u come to know which user was deleted? If he deleted alert log file
also how u come to know?
By using AUDITING.
4. What are the different Levels of Auditing?Statement Auditing, Privilege Auditing and Object
Auditing.
5. What is Statement Auditing?Statement auditing is the auditing of the powerful system privileges
without regard to specifically named objects6. What are the database administrator’s utilities
available?SQL * DBA - This allows DBA to monitor and control an ORACLE database. SQL * Loader -
It loads data from standard operating system files (Flat files) into ORACLE database tables.
Export (EXP) and Import (imp) utilities allow you to move existing data in ORACLE
format to and from ORACLE database.
7. What is Privilege Auditing?Privilege auditing is the auditing of the use of powerful system
privileges without regard to specifically named objects.
8. What is Object Auditing?Object auditing is the auditing of accesses to specific schema objects
without regard to user.
10. Oracle 11g new feature in auditing level?Oracle Audit Vault is a new feature that will provide a
solution to help customers address the most difficult security problems remaining today, protecting
against insider threat and meeting regulatory compliance requirements.
NK-8125652330
11. Is it Mandatory to mention log file in Sql Loader?
No. Once you load data then automatically logfile will be created
13. A file consists of 10 records. How can you load 5th and 6th records.
Sqlloader control=<controlfilename> skip=4 load=2
15. Can you insert some records for a non empty table?
No. It is not possible to insert the table should be empty
NK-8125652330
RECOVERY MANAGER
Incremental backups
Incremental backup stores only blocks changed since a previous backup
Thus, they provide more compact backups and faster recovery, thereby reducing the need to apply
redo during datafile media recovery
Unused block compression:
In unused block compression, RMAN can skip data blocks that have never been used
Binary compression
A binary compression mechanism integrated into Oracle Database reduces the size of
backups
Encrypted backups
RMAN uses backup encryption capabilities integrated into Oracle Database to store
backup sets in an encrypted format
NK-8125652330
3) How RMAN works?
RMAN backup and recovery operation for a target database are managed by RMAN client
RMAN uses the target database control file to gather metadata about the target database and to
store information about its own operations
The RMAN client itself does not perform backup, restore, or recovery operations
When you connect the RMAN client to a target database, RMAN allocates server sessions on the
target instance and directs them to perform the operations
The work of backup and recovery is performed by server sessions running on the target database
A channel establishes a connection from the RMAN client to a target or auxiliary database instance
by starting a server session on the instance
The channel reads data into memory, processes it, and writes it to the output device
When you take a database backup using RMAN, you need to connect to the target database using
RMAN Client
The RMAN client can use Oracle Net to connect to a target database, so it can be located on any
host that is connected to the target host through Oracle Net
For backup you need to allocate explicit or implicit channel to the target database
An RMAN channel represents one stream of data to a device, and corresponds to one database
server session.
This session dynamically collect information of the files from the target database control file before
taking the backup or while restoring
For example if you give ' Backup database ' from RMAN, it will first get all the datafiles information
from the controlfile
Then it will divide all the datafiles among the allocated channels. (Roughly equal size of work as per
the datafile size)
Then it takes the backup in 2 steps
Step1:
The channel will read all the Blocks of the entire datafile to find out all the formatted blocks to
backup
Note:
RMAN do not take backup of the unformatted blocks
Step2:
In the second step it takes back up of the formatted blocks
Example:
This is the best advantage of using RMAN as it only takes back up of the required blocks
Lets say in a datafile of 100 MB size, there may be only 10 MB of use full data and rest 90 MB is
free then RMAN will only take backup of those 10 MB
NK-8125652330
5) RMAN terminology:
A target database:
An Oracle database to which RMAN is connected with the TARGET keyword
A target database is a database on which RMAN is performing backup and recovery operations
RMAN always maintains metadata about its operations on a database in the control file of the
database
A recovery Catalog:
A separate database schema used to record RMAN activity against one or more target databases
A recovery catalog preserves RMAN repository metadata if the control file is lost, making it much
easier to restore and recover following the loss of the control file
The database may overwrite older records in the control file, but RMAN maintains records forever in
the catalog unless deleted by the user
Backup sets:
RMAN can store backup data in a logical structure called a backup set, which is the smallest unit of
an RMAN backup
One backup set contains one or more datafiles a section of datafile or archivelogs
Backup Piece:
A backup set contains one or more binary files in an RMAN-specific format
This file is known as a backup piece
Each backup piece is a single output file
The size of a backup piece can be restricted; if the size is not restricted, the backup set will
comprise one backup piece
Backup piece size should be restricted to no larger than the maximum file size that your filesystem
will support
Image copies:
An image copy is a copy of a single file (datafile, archivelog, or controlfile)
It is very similar to an O/S copy of the file
It is not a backupset or a backup piece
No compression is performed
Snapshot Controlfile:
When RMAN needs to resynchronize from a read-consistent version of the control file,
it creates a temporary snapshot control file
The default name for the snapshot control file is port-specific
Database Incarnation:
Whenever you perform incomplete recovery or perform recovery using a backup
control file, you must reset the online redo logs when you open the database
The new version of the reset database is called a new incarnation
The reset database command directs RMAN to create a new database incarnation record in the
recovery catalog
This new incarnation record indicates the current incarnation
The RMAN backup and recovery environment is preconfigured for each target database
NK-8125652330
The configuration is persistent and applies to all subsequent operations on this target database,
even if you exit and restart RMAN
RMAN configured settings can specify backup devices, configure a connection to a backup device ,
policies affecting backup strategy, encryption algorithm, snap shot controlfile loaion and others
By default there are few default configuration are set when you login to RMAN
You can customize them as per your requirement
Any time you can check the current setting by using the "Show all” command
CONFIGURE command is used to create persistent settings in the RMAN environment, which apply
to all subsequent operations, even if you exit and restart RMAN
You can have multiple catalog databases for the same target database
But at a time you can connect to only 1 catalog database via RMAN. Its not recommended to have
multiple catalog database
13) What is the difference between catalog database & catalog schema?
Catalog database is like any other database which contains the RMAN catalog user's
schema
NK-8125652330
All the backup information from the target database current controlfile will be updated to the catalog
schema
If any backup information which is aged out from the target database then you need to manually
catalog those backup pieces
RMAN backup:
15) What are the database file's that RMAN can backup?
RMAN can backup Controlfile, Datafiles, Archive logs, standby database controfile,
Spfile
16) What are the database file's that RMAN cannot backup?
RMAN can not take backup of the pfile, Redo logs, network configuration files,
password files, external tables and the contents of the Oracle home files
No. We can not put datafiles and archive logs in the same backupset
18) Can I have datafiles and contolfile backup in a single backup set?
Yes
If the controlfile autobackup is not ON then RMAN takes backup of controlfile along
with the datafile 1, whenever you take backup of the database or System tablespace
19) Can I regulate the size of backup piece and backup set?
Yes!
You can set max size of the backupset as well as the backup piece
By default one RMAN channel creates a single backupset with one backup piece in it
You can use the MAXPIECESIZE channel parameter to set limits on the size of backup pieces
You can also use the MAXSETSIZE parameter on the BACKUP and CONFIGURE commands to set a
limit for the size of backup sets
20) What is the difference between backup set backup and Image copy backup?
A backup set is an RMAN-specific proprietary format, whereas an image copy is a bit-
for-bit copy of a file
By default, RMAN creates backup sets
NK-8125652330
23) Do I need to place the database in begin backup mode while taking RMAN inconsistent backup?
RMAN does not require extra logging or backup mode because it knows the format of
data blocks
RMAN is guaranteed not to back up fractured blocks
No extra redo is generated during RMAN backup
Note:
RMAN compressed backup with BZIP2 provides great compression but is CPU intensive
Using ZLIB compression requires the Oracle Database 11g Advanced Compression Option and is
only supported with an 11g database
The feature is not backward compatible with 10g databases
Yes!
We can use RMAN for the tape backup
But RMAN can not able to write directly to tape
You need to have third party Media Management Software installed
Oracle has published an API specification which Media Management Vendor's who are members of
Oracle's Backup Solutions Partner program have access to
Media Management Vendors (MMVs) then write an interface library which the Oracle server uses to
write and read to and from tape
Starting from oracle 10g R2 oracle has its Own Media management software for the database backup
to tape called OSB
Before performing backup or restore to a media manager, you must allocate one or more channels
or configure default channels for use with the media manager to handle the communication with the
media manager
RMAN does not issue specific commands to load, label, or unload tapes
When backing up, RMAN gives the media manager a stream of bytes and associates a unique name
with this stream
When RMAN needs to restore the backup, it asks the media manager to retrieve the byte stream
All details of how and where that stream is stored are handled entirely by the media manager
NK-8125652330
28) What is Proxy copy backup to tape?
Proxy copy is functionality, supported by few media manager in which they handle the entire data
movement between datafiles and the backup devices
Such products may use technologies such as high-speed connections between storage and media
subsystems to reduce load on the primary database server
RMAN provides a list of files requiring backup or restore to the media manager, which in turn makes
all decisions regarding how and when to move the data
Oracle Secure Backup is a media manager provided by oracle that provides reliable and secure data
protection through file system backup to tape
All major tape drives and tape libraries in SAN, Gigabit Ethernet, and SCSI environments are
supported
30) Can I restore or duplicate my previous version database using a later version of Oracle?
For example, is it possible to restore a 9i backup while using the 10g executables?
It is possible to use the 10.2 RMAN executable to restore a 9.2 database (same for 11.2 to 11.1 or
11.1 to 10.2, etc) even if the restored datafiles will be stored in ASM
RMAN is configured so that a higher release is able to restore a lower release, but it is strongly
suggested you use only the same version
As you can restore between different Oracle versions, you can also do so between two different
patchset levels
Alter database open resetlogs upgrade;
OR
alter database open resetlogs downgrade;
32) Can I restore or duplicate between two different versions of the same operating system?
For example, can I restore my 9.2.0.1.0 RMAN backup taken against a host running Solaris 9 to a
different machine where 9.2.0.1.0 is installed but where that host is running Solaris 10?
If the same Oracle Server installation CDs (media pack) can be used to install 9.2.0.1.0 on Solaris 9
and Solaris 10, this type of restore is supportable
33) Is it possible to restore or duplicate when the bit level (32 bit or 64 bit) of Oracle does not
match?
For example, is it possible to restore or duplicate my 9.2. 64-bit database to a 9.2.32-bit installation?
It is preferable to keep the same bit version when performing a restore/recovery
However, excluding the use of duplicate command, the use of the same operating system platform
should allow for a restore/recovery between bit levels (32 bit or 64 bit) of Oracle
Note, this may be specific to the particular operating system and any problems with this should be
reported to Oracle Support
If you will be running the 64-bit database against the 32-bit binary files or vice versa, after the
recovery has ended the database bit version must be converted using utlirp.sql
If you do not run utlirp.sql you will see errors including but not limited to:
ORA-06553: PLS-801: INTERNAL ERROR [56319]
34) Can I restore or duplicate my RMAN backup between two different platforms such as Solaris to
NK-8125652330
Linux?
In general, you cannot restore or duplicate between two different platforms
Scenarios:
Goal: How to identify all the corrupted segments in the database reported by RMAN?
Solution:
Step 1: Identify the corrupt blocks (Datafile Block Corruption - Intra block corruption)
RMAN> backup validate check logical database;
RMAN> run {
allocate channel d1 type disk;
allocate channel d2 type disk;
allocate channel d3 type disk;
allocate channel d4 type disk;
backup validate check logical database;
}
5 rows selected.
Solution1:
$ rman target /
NK-8125652330
RMAN> backup check logical validate database;
$ rman target /
RMAN> backup check logical database;
Solution2:
ü Chek the view V$DATABASE_BLOCK_CORRUPTION to identify the block corruptions detected by
RMAN
dbv file= blocksize=
When the logical option is used by RMAN, it does exactly the same checks as DBV does for intra
block corruption.
RMAN can be run with PARALLELISM using multiple channels making it faster than DBV which can
not be run in parallel in a single command
DBV checks for empty blocks. In 10g RMAN may not check blocks in free extents when Locally
Managed Tablespaces are used. In 11g RMAN checks for both free and used extents.
Both DBV and RMAN (11g) can check for a range of blocks. RMAN: VALIDATE DATAFILE 1 BLOCK 10
to 100;. DBV: start=10 end=100
RMAN keeps corruption information in the control file (v$database_block_corruption,
v$backup_corruption). DBV does not.
RMAN may not report the corruption details like what is exactly corrupted in a block reported as a
LOGICAL corrupted block. DBV reports the corruption details in the screen or in a log file.
DBV can scan blocks with a higher SCN than a given SCN.
DBV does not need a connection to the database.
When an inconsistency is identified, the above analyze command will produce error ORA-1499 and a
trace file.
One danger in making online backups is the possibility of inconsistent data within a block For
example, assume that you are backing up block 100 in datafile users. dbf Also, assume that the
copy utility reads the entire block while DBWR is in the middle of updating the block
In this case, the copy utility may read the old data in the top half of the block and the new data in
the bottom top half of the block The result is called a fractured block, meaning that the data
NK-8125652330
contained in this block is not consistent at a given SCN
2. The datafile headers which contain the SCN of the last completed checkpoint are not updated
while a file is in hot backup mode. This lets the recovery process understand what archive redo log
files might be needed to fully recover this file.
ANS:When new incarnation happens, the old backup information in control file will be lost.
It will be preserved in recovery catalog.
In recovery catalog, we can store scripts.
Recovery catalog is central and can have information of many databases.
ANS:No.
The recovery catalog should not reside in the target database (database to be backed up),
because the database can't be recovered in the mounted state.
LIST:The primary purpose of the LIST command is to list backup and copies. For example, you can
list:
NK-8125652330
Backups and proxy copies of a database, tablespace, datafile, archived redo log, or control file
Backups that have expired
Backups restricted by time, path name, device type, tag, or recoverability
Archived redo log files and disk copies
REPORT:
You can use the REPORT command to answer important questions, such as:
Which files need a backup?
Which files have had unrecoverable operations performed on them?
Which backups are obsolete and can be deleted?
What was the physical schema of the target database or a database in the Data Guard environment
at some previous time?
Which files have not been backed up recently?
ANS:
RMAN> delete archivelog all completed before sysdate-7;
ANS:
Crosscheck will be useful to check whether the catalog information is intact with OS level
information.
A cumulative backup, which backs up all blocks changed after the most recent incremental backup at
level 0
A level 0 incremental backup, which is the base for subsequent incremental backups, copies all
blocks containing data,
backing the datafile up into a backup set just as a full backup would.
A level 1 incremental backup can be either of the following types:
A differential backup, which backs up all blocks changed after the most recent incremental backup at
level 1 or 0
A cumulative backup, which backs up all blocks changed after the most recent incremental backup at
level 0
NK-8125652330
11) Can we perform level 1 backup without level 0 backup?
ANS:
If no level 0 backup is available, then the behavior depends upon the compatibility mode setting.
If compatibility < 10.0.0, RMAN generates a level 0 backup of the file contents at the time of the
backup.
If compatibility is >= 10.0.0, RMAN copies all blocks changed since the file was created, and stores
the results as a level 1 backup.
In other words, the SCN at the time the incremental backup is taken is the file creation SCN.
RMAN does not require you to put the database in backup mode.
15) What is the difference between backup set and backup piece?
ANS:
A status of "expired" means that the backup piece or backup set is not found in the backup
destination.
A status of "obsolete" means the backup piece is still available, but it is no longer needed.
The backup piece is no longer needed since RMAN has been configured to no longer need this piece
after so many days have elapsed,
or so many backups have been performed.
17) What is the difference between hot backup & RMAN backup?
NK-8125652330
For hot backup, we have to put database in begin backup mode, then take backup.
RMAN won’t put database in backup mode.
19) What is the difference between auxiliary channel and maintenance channel ?
AUXILIARY:
Specifies a connection between RMAN and an auxiliary database instance.
An auxiliary instance is used when executing the DUPLICATE or TRANSPORT TABLESPACE command,
and when performing TSPITR with RECOVER TABLESPACE . When specifying this option, the auxiliary
instance must be started but not mounted.
See Also: DUPLICATE to learn how to duplicate a database, and CONNECT to learn how to connect to
a duplicate database instance
CHANNEL:
NK-8125652330
When you moved oracle binary files from one ORACLE_HOME server to another server then which
oracle utility will be used to make this new ORACLE_HOME usable?
Relink all.
You have collection of patch (nearly 100 patches) or patchset. How can you apply only one patch
from it?
With Napply itself (by providing patch location and specific patch id) you can apply only one patch
from a collection of extracted patch. For more information check the opatch util NApply –help. It will
give you clear picture.
For Example:
opatch util napply <patch_location> -id 9 -skip_subset -skip_duplicate
This will apply only the patch id 9 from the patch location and will skip duplicate and subset of patch
installed in your ORACLE_HOME.
If both CPU and PSU are available for given version which one, you will prefer to apply?
From the above discussion it is clear once you apply the PSU then the recommended way is to apply
the next PSU only. In fact, no need to apply CPU on the top of PSU as PSU contain CPU (If you apply
CPU over PSU will considered you are trying to rollback the PSU and will require more effort in fact).
So if you have not decided or applied any of the patches then, I will suggest you to go to use PSU
patches. For more details refer: Oracle Products [ID 1430923.1], ID 1446582.1
PSU is superset of CPU then why someone choose to apply a CPU rather than a PSU?
CPUs are smaller and more focused than PSU and mostly deal with security issues. It seems to be
theoretically more consecutive approach and can cause less trouble than PSU as it has less code
changing in it. Thus any one who is concerned only with security fixes and not functionality fixes,
CPU may be good approach.
If you are using latest support.oracle.com then after login to metalink Dashboard
- Click on "Patches & Updates" tab
- On the left sidebar click on "Latest Patchsets" under "Oracle Server/Tools".
- A new window will appear.
- Just mouseover on your product in the "Latest Oracle Server/Tools Patchsets" page.
- Corresponding oracle platform version will appear. Then simply choose the patchset version and
click on that.
NK-8125652330
- You will go the download page. From the download page you can also change your platform and
patchset version.
REFERENCES:
http://docs.oracle.com/cd/E11857_01/em.111/e12255/e_oui_appendix.htm
Oracle® Universal Installer and OPatch User's Guide
11g Release 2 (11.2) for Windows and UNIX
Part Number E12255-11
What is OPatch?
1. You MUST read the Readme.txt file included in opatch file, look for any prereq. steps/ post
installation steps or and DB related changes. Also, make sure that you have the correct opatch
version required by this patch.
2.Make sure you have a good backup of database.
3. Make a note of all Invalid objects in the database prior to the patch.
4. Shutdown All the Oracle Processes running from that Oracle Home , including the Listener and
Database instance, Management agent etc.
5. You MUST Backup your oracle Home and Inventory
tar -cvf $ORACLE_HOME $ORACLE_HOME/oraInventory | gzip > Backup_Software_Version.tar.gz
6. Unzip the patch in $ORACLE_HOME/patches
7. cd to the patch direcory and do opatch -apply to apply the patch.
8. Read the output/log file to make sure there were no errors.
1. Download the required Patch from Metalink based on OS Bit Version and DB Version.
2. Need to down the database before applying patch.
3. Unzip and Apply the Patch using ”opatch apply” command.On successfully applied of patch you will
see successful message “OPatch succeeded.“, Crosscheck your patch is applied by using “opatch
lsinventory” command .
4. Each patch has a unique ID, the command to rollback a patch is “opatch rollback -id <patch
no.>” command.On successfully applied of patch you will see successful message “OPatch
succeeded.“, Crosscheck your patch is applied by using “opatch lsinventory” command .
5. Patch file format will be like, “p<patch no.>_<db version>_<os>.zip”
6. We can check the opatch version using “opatch -version” command.
7. Generally, takes 2 minutes to apply a patch.
8. To get latest Opatch version download “patch 6880880 - latest opatch tool”, it contains OPatch
directory.
9. Contents of downloaded patches will be like “etc,files directories and a README file”
NK-8125652330
10. Log file for Opatch utility can be found at $ORACLE_HOME/cfgtoollogs/opatch
11. OPatch also maintains an index of the commands executed with OPatch and the log files
associated with it in the history.txt file located in the <ORACLE_HOME>/cfgtoollogs/opatch directory.
12. Starting with the 11.2.0.2 patch set, Oracle Database patch sets are full installations of the
Oracle Database software. This means that you do not need to install Oracle Database 11g Release 2
(11.2.0.1) before installing Oracle Database 11g Release 2 (11.2.0.2).
13. Direct upgrade to Oracle 10g is only supported if your database is running one of the following
releases: 8.0.6, 8.1.7, 9.0.1, or 9.2.0. If not, you will have to upgrade the database to one of these
releases or use a different upgrade option (like export/ import).
14.Direct upgrades to 11g are possible from existing databases with versions 9.2.0.4+, 10.1.0.2+ or
10.2.0.1+. Upgrades from other versions are supported only via intermediate upgrades to a
supported upgrade version.
http://avdeo.com/2008/08/19/opatch-utility-oracle-rdbms-patching/
Types of Patches?
What is PSU?
REFERENCES:
OPATCH Utility (Oracle RDBMS Patching)
http://avdeo.com/2008/08/19/opatch-utility-oracle-rdbms-patching/
NK-8125652330
Oracle Database 11.2.0.2 Patch Set (English)
http://www.dbacomp.com.br/blog/?p=69
Upgrade
=======
What is rolling upgrade?It is a new ASM feature from Database 11g.ASM instances in Oracle
database 11g release(from 11.1) can be upgraded or patched using rolling upgrade feature. This
enables us to patch or upgrade ASM nodes in a clustered environment without affecting database
availability.During a rolling upgrade we can maintain a functional cluster while one or more of the
nodes in the cluster are running in different software versions.Rolling upgrade can be used only for
Oracle database 11g releases(from 11.1).
Note:
----
The UPGRADE keyword enables you to open a database based on an earlier Oracle Database release.
It also restricts logons to AS SYSDBAsessions, disables system triggers, and performs additional
operations that prepare the environment for the upgrade.
You might be required to use the PFILE option to specify the location of your initialization parameter
file.
Once the database is started in upgrade mode, only queries on fixed views execute without errors
until after the catupgrd.sql script is run. Before running catupgrd.sql, queries on any other view or
the use of PL/SQL returns an error.
startup migrate:
NK-8125652330
---------------
Used to upgrade a database till 9i.
Startup Upgrade
---------------
From 10G we are using startup upgrade to upgrade database.
It will adjust few database (init) parameters (irrespective of what you have defined) automatically to
certain values in order to run upgrade scripts smoothely.
in other way..it will issue few alter statements to set certain parameters which are required to
complete the upgrade scripts without any issues.
REFERENCE:
---------
Oracle® Database Upgrade Guide 11g Release 2 (11.2)
http://docs.oracle.com/cd/E11882_01/server.112/e23633/upgrade.htm
NK-8125652330
Query to check timezone file is:
SQL> select * from v$timezone_file;
FILENAME VERSION
———— ———-
timezlrg.dat 4
SQL> select * from v$timezone_file;
FILENAME VERSION
———— ———-
timezlrg.dat 4
So I had correct version.I remember applying patch before upgrade.I got lucky because patch
existed for version 10.2.0.3.
If there is no patch for your Oracle versions than patch can be download for similar version and
applied manually.
Instructions are below:
1. Download the identified patch.
2. Unzip the patch, and locate the 2 files timezone.dat and timezlrg.dat in the
“files/oracore/zoneinfo” directory of the uncompressed patch (or from the relevant .jar file of a
patchset). If there is also a readme.txt in this location then make a note of this as well.
3. Backup your existing files in $ORACLE_HOME/oracore/zoneinfo – THIS CAN BE VITAL, DO NOT
SKIP.
Note:
Before going on with step 4, make sure the current files are not in use.
On Windows the files will simply refuse to be removed when the are in use.
On Unix replacing the files whilst they are in use can cause the files to become corrupt. Use the fuser
command before replacing the files to make sure they are not in use.
4. Copy the 2 .dat files and possibly the readme.txt file that were found in step 2 into the
$ORACLE_HOME/oracore/zoneinfo directory.
5. Restart the database (in case of installation on a database), or restart the client applications (in
case of client install). Note that the database did not need to be down before the time zone files were
applied, but it does need to be restarted afterwards.
NK-8125652330
1. What is use of CONSISTENT option in exp?
Cross-table consistency. Implements SET TRANSACTION READ ONLY. Default value N.
5. How to improve imp performance?
1. Place the file to be imported in separate disk from datafiles.
2. Increase the DB_CACHE_SIZE.
3. Set LOG_BUFFER to big size.
4. Stop redolog archiving, if possible.
5. Use COMMIT=n, if possible.
6. Set the BUFFER parameter to a high value. Default is 256KB.
7. It's advisable to drop indexes before importing to speed up the import process or set INDEXES=N
and building indexes later on after the import. Indexes can easily be recreated after the data was
successfully imported.
8. Use STATISTICS=NONE
9. Disable the INSERT triggers, as they fire during import.
10. Set Parameter COMMIT_WRITE=NOWAIT(in Oracle 10g) or COMMIT_WAIT=NOWAIT (in Oracle
11g) during import.
8. What are the differences between expdp and exp (Data Pump or normal exp/imp)?
Data Pump is server centric (files will be at server).
Data Pump has APIs, from procedures we can run Data Pump jobs.
In Data Pump, we can stop and restart the jobs.
Data Pump will do parallel execution.
Tapes & pipes are not supported in Data Pump.
Data Pump consumes more undo tablespace.
Data Pump import will create the user, if user doesn’t exist.
NK-8125652330
9. Why expdp is faster than exp (or) why Data Pump is faster than conventional export/import?
Data Pump is block mode, exp is byte mode.
Data Pump will do parallel execution.
Data Pump uses direct path API.
12. In Data Pump, where the jobs info will be stored (or) if you restart a job in Data Pump, how it
will know from where to resume?
Whenever Data Pump export or import is running, Oracle will create a table with the JOB_NAME and
will be deleted once the job is done. From this table, Oracle will find out how much job has
completed and from where to continue etc.
Default export job name will be SYS_EXPORT_XXXX_01, where XXXX can be FULL or SCHEMA or
TABLE.
Default import job name will be SYS_IMPORT_XXXX_01, where XXXX can be FULL or SCHEMA or
TABLE.
17. Using Data Pump, how to export in higher version (11g) and import into lower version (10g), can
we import to 9i?
NK-8125652330
18. Using normal exp/imp, how to export in higher version (11g) and import into lower version
(10g/9i)?
Flashback Technology
1. Will a normal user is able to use flashback transaction query?
NK-8125652330
No
6. Can any user present in dictionary managed tablespace use recycle bin?
No
7. What is flashback data archive?A Flashback Data Archive provides the ability to track and store all
transactional changes to a table over its lifetime. It is no longer necessary to build this intelligence
into your application. A Flashback Data Archive is useful for compliance with record stage policies
and audit reports.A Flashback Data Archive is configured with retention time. Data archived in the
Flashback Data Archive is retained for the retention time.
By default, flashback archiving is off for any table. You can enable flashback archiving for a table if
you have the FLASHBACK ARCHIVE object privilege on the Flashback Data Archive that you want to
use for that table. After flashback archiving is enabled for a table, you can disable it only if you either
have the FLASHBACK ARCHIVE ADMINISTER system privilege or you are logged on as SYSDBA.
8. Limitations of data archive?
There are a number of restrictions for flashback archives:The tablespaces used for a flashback
archive must use local extent management and automatic segment space management. The
database must use automatic undo management.
9.Database views useful to view information about flashback data archive? Viewing information about
FLASHBACK ARCHIVE DATA
dba_FLASHBACK_ARCHIVE display information about flashback data archive
dba_FLASHBACK_ARCHIVE_TS display tablespaces of flashback data archive
dba_FLASHBACK_ARCHIVE_TABLES display information about tables that are enabled for flashback
archiving.
NK-8125652330
10. Advantages of data archive?
The primary advantages of using Flashback Data Archive for historical data tracking include:
1.Application transparency
2. Seamless access
3. Security
4. Minimal performance overhead
5. Storage optimization
6. Centralized management
DATA GUARD
NK-8125652330
What are the types of Oracle Data Guard?
Oracle Data Guard classified in to two types based on way of creation and method used for Redo
Apply. They are as follows.
Following are the different benefits in using Oracle Data Guard feature in your environment.
1. High Availability.
2. Data Protection.
3. Off loding Backup operation to standby database.
4. Automatic Gap detection and Resolution in standby database.
5. Automatic Role Transition using Data Guard Broker.
What are the different services available in Oracle Data Guard?
Following are the different Services available in Oracle Data Guard of Oracle database.
1. Maximum Protection
2. Maximum Availability
3. Maximum Performance
How to check what protection mode of primary database in your Oracle Data Guard?
By using following query you can check protection mode of primary database in your Oracle Data
Guard setup.
For Example:
PROTECTION_MODE
——————————–
MAXIMUM PERFORMANCE
By using following query you can change the protection mode in your primary database after setting
up required value in corresponding LOG_ARCHIVE_DEST_n parameter in primary database for
corresponding standby database.
NK-8125652330
Example:
What are the advantages of using Physical standby database in Oracle Data Guard?
Advantages of using Physical standby database in Oracle Data Guard are as follows.
High Availability.
Load balancing (Backup and Reporting).
Data Protection.
Disaster Recovery.
What is physical standby database in Oracle Data Guard?
Oracle Standby database are divided into physical standby database or logical standby database
based on standby database creation and redo log apply method. Physical standby database are
created as exact copy i.e block by block copy of primary database. In physical standby database
transactions happen in primary database are synchronized in standby database by using Redo Apply
method by continuously applying redo data on standby database received from primary database.
Physical standby database can offload the backup activity and reporting activity from Primary
database. Physical standby database can be opened for read-only transactions but redo apply won’t
happen during that time. But from 11g onwards using Active Data Guard option (extra purchase) you
can simultaneously open the physical standby database for read-only access and apply redo logs
received from primary database.
Oracle Standby database are divided into physical standby database or logical standby database
based on standby database creation and redo log apply method. Logical standby database can be
created similar to Physical standby database and later you can alter the structure of logical standby
database. Logical standby database uses SQL Apply method to synchronize logical standby database
with primary database. This SQL apply technology converts the received redo logs to SQL statements
and continuously apply those SQL statements on logical standby database to make standby database
consistent with primary database. Main advantage of Logical standby database compare to physical
standby database is you can use Logical standby database for reporting purpose during SQL apply i.e
Logical standby database must be open during SQL apply. Even though Logical standby database are
opened for read/write mode, tables which are in synchronize with primary database are available for
read-only operations like reporting, select queries and adding index on those tables and creating
materialized views on those tables. Though Logical standby database has advantage on Physical
standby database it has some restriction on data-types, types of DDL, types of DML and types of
tables.
What are the advantages of Logical standby database in Oracle Data Guard?
NK-8125652330
What is the usage of LOG_FILE_NAME_CONVERT parameter in Oracle Data Guard setup?
FROM v$archived_log
V$ log_history
Log_Archive_Dest_n
Log_Archive_Dest_State_n
Log_Archive_Config
Log_File_Name_Convert
Standby_File_Managment
DB_File_Name_Convert
DB_Unique_Name
Control_Files
NK-8125652330
Fat_Client
Fat_Server
The LOG_ARCHIVE_CONFIG parameter enables or disables the sending of redo streams to the
standby sites. The DB_UNIQUE_NAME of the primary database is dg1 and the DB_UNIQUE_NAME of
the standby database is dg2. The primary database is configured to ship redo log stream to the
standby database. In this example, the standby database service is dg2.
Next, STANDBY_FILE_MANAGEMENT is set to AUTO so that when Oracle files are added or dropped
from the primary database, these changes are made to the standby databases automatically. The
STANDBY_FILE_MANAGEMENT is only applicable to the physical standby databases.
What is Dataguard?
Data Guard provides a comprehensive set of services that create, maintain, manage, and monitor
one or more standby databases to enable production Oracle databases to survive disasters and data
corruptions. Data Guard maintains these standby databases as copies of the production database.
Data Guard can be used with traditional backup, restoration, and cluster techniques to provide a high
level of data protection and data availability.
What is DG Broker?
DG Broker “it is the management and monitoring tool”.
Oracle dataguard broker is a distributed management framework that automates and centralizes the
creation , maintenance and monitoring of DG configuration.
All management operations can be performed either through OEM, which uses the broker (or) broker
specified command-line tool interface “DGMGRL”.
Dataguard :
Dataguard is mechanism/tool to maintain standby database.
The dataguard is set up between primary and standby instance .
Data Guard is only available on Enterprise Edition.
Standby Database :
Physical standby database provides a physically identical copy of the primary database, with on disk
database structures that are identical to the primary database on a block-for-block basis.
Standby capability is available on Standard Edition.
What are the differences between Physical/Logical standby databases? How would you decide which
one is best suited for your environment?
Physical standby DB:
NK-8125652330
As the name, it is physically (datafiles, schema, other physical identity) same copy of the primary
database.
It synchronized with the primary database with Apply Redo to the standby DB.
Logical Standby DB:
As the name logical information is the same as the production database, it may be physical structure
can be different.
It synchronized with primary database though SQL Apply, Redo received from the primary database
into SQL statements and then executing these SQL statements on the standby DB.
We can open “physical stand by DB to “read only” and make it available to the applications users
(Only select is allowed during this period). we can not apply redo logs received from primary
database at this time.
We do not see such issues with logical standby database. We can open the database in normal mode
and make it available to the users. At the same time, we can apply archived logs received from
primary database.
For OLTP large transaction database it is better to choose logical standby database.
NK-8125652330
Like a physical or logical standby database, a snapshot standby database receives and archives redo
data from a primary database. Unlike a physical or logical standby database, a snapshot standby
database does not apply the redo data that it receives. The redo data received by a snapshot
standby database is not applied until the snapshot standby is converted back into a physical standby
database, after first discarding any local updates made to the snapshot standby database.
REFERENCE:
http://docs.oracle.com/cd/B28359_01/server.111/b28294/title.htm
What is the Default mode will the Standby will be, either SYNC or ASYNC?
ASYNC
Dataguard Architechture?
Data Guard Configurations:
A Data Guard configuration consists of one production database and one or more standby databases.
The databases in a Data Guard configuration are connected by Oracle Net and may be dispersed
geographically. There are no restrictions on where the databases are located, provided they can
communicate with each other.
Dataguard Architecture
The Oracle 9i Data Guard architecture incorporates the following items:
• Primary Database – A production database that is used to create standby databases. The archive
logs from the primary database are transfered and applied to standby databases. Each standby can
only be associated with a single primary database, but a single primary database can be associated
with multiple standby databases.
• Standby Database – A replica of the primary database.
• Log Transport Services – Control the automatic transfer of archive redo log files from the primary
database to one or more standby destinations.
• Network Configuration – The primary database is connected to one or more standby databases
using Oracle Net.
• Log Apply Services – Apply the archived redo logs to the standby database. The Managed Recovery
Process (MRP) actually does the work of maintaining and applying the archived redo logs.
• Role Management Services – Control the changing of database roles from primary to standby. The
services include switchover, switchback and failover.
• Data Guard Broker – Controls the creation and monitoring of Data Guard. It comes with a GUI and
command line interface.
Primary Database:
A Data Guard configuration contains one production database, also referred to as the primary
database, that functions in the primary role. This is the database that is accessed by most of your
applications.
Standby Database:
A standby database is a transactionally consistent copy of the primary database. Using a backup
copy of the primary database, you can create up to nine standby databases and incorporate them in
a Data Guard configuration. Once created, Data Guard automatically maintains each standby
database by transmitting redo data from the primary database and then applying the redo to the
NK-8125652330
standby database.
The types of standby databases are as follows:
What are the services required on the primary and standby database ?
The services required on the primary database are:
• Log Writer Process (LGWR) – Collects redo information and updates the online redo logs. It can
also create local archived redo logs and transmit online redo to standby databases.
• Archiver Process (ARCn) – One or more archiver processes make copies of online redo logs either
locally or remotely for standby databases.
• Fetch Archive Log (FAL) Server – Services requests for archive redo logs from FAL clients running
on multiple standby databases. Multiple FAL servers can be run on a primary database, one for each
FAL request. .
The services required on the standby database are:
• Fetch Archive Log (FAL) Client – Pulls archived redo log files from the primary site. Initiates
transfer of archived redo logs when it detects a gap sequence.
• Remote File Server (RFS) – Receives archived and/or standby redo logs from the primary database.
• Archiver (ARCn) Processes – Archives the standby redo logs applied by the managed recovery
process (MRP).
• Managed Recovery Process (MRP) – Applies archive redo log information to the standby database.
NK-8125652330
requirements of the configured data protection mode and that does not have a redo gap. Redo gaps
are discussed in Section 6.3.3.
Maximum Availability
This protectionmode provides the highest level of data protection that is possible without
compromising the availability of a primary database. Transactions do not commit until all redo data
needed to recover those transactions has been written to the online redo log and to at least one
synchronized standby database. If the primary database cannot write its redo stream to at least one
synchronized standby database, it operates as if it were in maximum performance mode to preserve
primary database availability until it is again able to write its redo stream to a synchronized standby
database.
This mode ensures that no data loss will occur if the primary database fails, but only if a second fault
does not prevent a complete set of redo data from being sent from the primary database to at least
one standby database.
Maximum Performance
This protectionmode provides the highest level of data protection that is possible without affecting
the performance of a primary database. This is accomplished by allowing transactions to commit as
soon as all redo data generated by those transactions has been written to the online log. Redo data
is also written to one or more standby databases, but this is done asynchronously with respect to
transaction commitment, so primary database performance is unaffected by delays in writing redo
data to the standby database(s).
This protection mode offers slightly less data protection than maximum availability mode and has
minimal impact on primary database performance.
This is the default protection mode.
Maximum Protection
This protection mode ensures that zero data loss occurs if a primary database fails. To provide this
level of protection, the redo data needed to recover a transaction must be written to both the online
redo log and to at least one synchronized standby database before the transaction commits. To
ensure that data loss cannot occur, the primary database will shut down, rather than continue
processing transactions, if it cannot write its redo stream to at least one synchronized standby
database.
Because this data protection mode prioritizes data protection over primary database availability,
Oracle recommends that a minimum of two standby databases be used to protect a primary
database that runs in maximum protection mode to prevent a single standby database failure from
causing the primary database to shut down.
A standby database automatically applies redo logs when they arrive from the primary database. But
in some cases, we want to create a time lag between the archiving of a redo log at the primary site,
and the application of the log at the standby site.
Modify the LOG_ARCHIVE_DEST_n initialization parameter on the primary database to set a delay for
the standby database.
NK-8125652330
Example: For 60min Delay:
ALTER SYSTEM SET LOG_ARCHIVE_DEST_2=’SERVICE=stdby_srvc DELAY=60′;
The DELAY attribute is expressed in minutes.
The archived redo logs are still automatically copied from the primary site to the standby site, but
the logs are not immediately applied to the standby database. The logs are applied when the
specified time interval expires.
DB_NAME=chicago
DB_UNIQUE_NAME=chicago
LOG_ARCHIVE_CONFIG=’DG_CONFIG=(chicago,boston)’
CONTROL_FILES=’/arch1/chicago/control1.ctl’, ‘/arch2/chicago/control2.ctl’
LOG_ARCHIVE_DEST_1=
‘LOCATION=/arch1/chicago/
VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
DB_UNIQUE_NAME=chicago’
LOG_ARCHIVE_DEST_2=
‘SERVICE=boston LGWR ASYNC
VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)
DB_UNIQUE_NAME=boston’
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
LOG_ARCHIVE_FORMAT=%t_%s_%r.arc
LOG_ARCHIVE_MAX_PROCESSES=30
NK-8125652330
Prepare an Initialization Parameter File for the Standby Database
—————————————————————–
Create a text initialization parameter file (PFILE) from the server parameter file (SPFILE) used by the
primary database; a text initialization parameter file can be copied to the standby location and
modified. For example:
CREATE PFILE=’/tmp/initboston.ora’ FROM SPFILE;
Modifying Initialization Parameters for a Physical Standby Database.
DB_NAME=chicago
DB_UNIQUE_NAME=boston
LOG_ARCHIVE_CONFIG=’DG_CONFIG=(chicago,boston)’
CONTROL_FILES=’/arch1/boston/control1.ctl’, ‘/arch2/boston/control2.ctl’
DB_FILE_NAME_CONVERT=’chicago’,’boston’
LOG_FILE_NAME_CONVERT= ‘/arch1/chicago/’,’/arch1/boston/’,’/arch2/chicago/’,’/arch2/boston/’
LOG_ARCHIVE_FORMAT=log%t_%s_%r.arc
LOG_ARCHIVE_DEST_1= ‘LOCATION=/arch1/boston/
VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
DB_UNIQUE_NAME=boston’
LOG_ARCHIVE_DEST_2= ‘SERVICE=chicago LGWR ASYNC
VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=chicago’
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
STANDBY_FILE_MANAGEMENT=AUTO
FAL_SERVER=chicago
FAL_CLIENT=boston
NK-8125652330
i
1. What is ASM?
ASM is one file system which will build by an oracle on any raw disk for storing oracle database
files including datafiles, redologs, Backups, controlfiles and spfiles. ASM allows administrators to
add and remove disks while the database is on-line and available to users. And also DBA can
manage storage of database with redundant technology. Data is automatically striped across all
disks in a diskgroup and is optionally mirrored.
2. What are disadvantages of having raw devices?One single raw device storage space is
completely dedicated to only any one datafile or any one redolog or to any one controlfile. The tar
command cannot be used for physical file backup; instead we should use dd command.
3. What is advantage of having disk shadowing/ Mirroring? Shadow set of disks save like a backup
for the safe-side of disk failure. In most Volume Manager if any disk failure occurs it automatically
switches over to a working disk. Improved performance because most OS support volume
shadowing can direct file I/O request to use the shadow set of files instead of the main set of files.
This reduces I/O load on the main set of disks.
4. 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. I/O will be improved and database performance
will increase.
Ans:
RABL- Rebalancer: It opens all the device files as part of disk discovery and coordinates the ARB
processes for rebalance activity.
ASMB - ASM Bridge: This process is used to provide information to and from the Cluster
Synchronization Service (CSS) used by ASM to manage the disk resources.
It is also used to update statistics and provide a heartbeat mechanism.
2) What is the use of ASM (or) Why ASM preferred over filesystem?
ANS:
INSTANCE_TYPE = ASM
ASM_POWER_LIMIT = 11
ASM_DISKSTRING = '/dev/rdsk/*s2', '/dev/rdsk/c1*'
ASM_DISKGROUPS = DG_DATA, DG_FRA
ANS:
ASM_POWER_LIMIT is dynamic parameter, which will be useful for rebalancing the data across disks.
Value can be 1(lowest) to 11 (highest).
ANS:
External redundancy,
Normal redundancy,
High redundancy.
6) How to copy file to/from ASM from/to filesystem?
ANS:
7) How to find out the databases, which are using the ASM instance?
ANS:
ASMCMD> lsct
DB_Name Status Software_Version Compatible_version Instance_Name Disk_Group
amxdcmp1 CONNECTED 11.2.0.2.0 11.2.0.2.0 amxdcmp1 DG1_DCM_DATA
amxddip1 CONNECTED 11.2.0.2.0 11.2.0.2.0 amxddip1 DG1_DDI_DATA
ASMCMD>
(or)
ANS:
Fine-grained striping
Coarse-grained striping
ASMCMD> lsdg
State Type Rebal Sector Block AU Total_MB Free_MB Req_mir_free_MB Usable_file_MB
Offline_disks Voting_files Name
MOUNTED EXTERN N 512 4096 1048576 6835200 1311391 0 1311391
0 N DG1_DCM_DATA/
MOUNTED EXTERN N 512 4096 1048576 486400 154487 0 154487
0 N DG1_DDI_DATA/
ASMCMD>
NAME MB
------------------------------ ----------
DG1_DCM_DATA 1
DG1_DDI_DATA 1
9) What is allocation unit and what is default value of au_size and how to change?
ANS:
ANS:
RBAL, ARBn
ANS:
add disk:
remove disk:
Things that can cause service outages:• Is the archive log destination filling up?
• Objects getting close to their max extents
• Tablespaces running low on free space/ Objects what
would not be able to extend
• User and process limits reached
4. What tuning indicators can a DBA use?The following high-level tuning indicators can be used to
establish if a database is performing optimally or not:
1 Buffer Cache Hit Ratio
Formula: Hit Ratio = (Logical Reads - Physical Reads) / Logical Reads
Action: Increase DB_CACHE_SIZE (DB_BLOCK_BUFFERS prior to 9i) to increase hit ratio
2Library Cache Hit Ratio
Action: Increase the SHARED_POOL_SIZE to increase hit ratio
5. What are the values that can be specified for OPTIMIZER MODE Parameter?
All_rows,rule,first_rows_1000,first_rows_100,first_rows_10,first_rows_1,choose,first_rows.
6. When you enable tracing for a SQL statement, where do you look for the trace files?
In 11g /disk1/oradata/prod/diag/rdbms/db_name/instance_name/trace In 10g
/disk1/oradata/prod/udump
8. What are the different approaches used by Optimizer in choosing an execution plan?
Rule-based and Cost-based.
9. What are the values that can be specified for OPTIMIZER MODE Parameter?
All_rows and rule.
10. What is COST-based approach to optimization?
Considering available access paths and determining the most efficient execution plan based on
statistics in the data dictionary for the tables accessed by the statement and their associated
clusters and indexes.
11. What is RULE-based approach to optimization?
Choosing an executing plan based on the access paths available and the ranks of these access
paths.
12. Diff between Production, Development& QA database?
PRODUCTION database is currently using by end users.
Development database using by developers.
14. How do you check the locks in the database and determine if there is any deadlock issue?
Transaction deadlocks occur when two or more transactions are attempting to access an object
with incompatible lock modes. The following script can be used to identify deadlocks in the
database. The query depends upon objects that are created by the
script ORACLE_HOME/rdbms/admin/dbmslock.sql. Log on as SYS or with SYSDBA authority and
run this script in all databases
Application Tuning
1. What is Parallel Server?Oracle Parallel Server is a robust computing environment that
harnesses the processing power of multiple, interconnected computers. Oracle Parallel Server
software and a collection of hardware known as a "cluster", unites the processing power of each
component to become a single, robust computing environment. A cluster generally comprises two
or more computers, or "nodes".(i.e) Multiple instances accessing the same database (Only In
Multi-CPU environments)
7. When 100 users connect to database,Hw u see which statement is taking long time and which
statement is doing physical reading in Performance Tuning?
By using explain plan or TKPROF
9. What is the cache hit ratio, what impact does it have on performance of anOracle database?For
the buffer cache hit ratio, it calculates how often a requested block has been found in the buffer
cache without requiring disk access. This ratio is computed using data selected from the dynamic
performance view V$SYSSTAT. The buffer cache hit ratio can be used to verify the physical I/O as
predicted by V$DB_CACHE_ADVICE.
10. How does u improve the performance of Report program?There are having in so many ways.
1) You can use the sort after Declare the buffering in Read statement.
2) You don't using inner joines You can use for all entries.
3) Maintain the Work area.
4) Maintain the Variables
11. What is the use of tkprof and how to generate it?Tkprof is one of the most useful utilities
available to DBAs for diagnosing performance issues. It essentially formats a trace file into a
more readable format for performance analysis. The DBA can then identify and resolve
performance issues such as poor SQL, indexing, and execution plan.
12. What would you do to increasing the buffer cache hit ratio?
If the hit ratio is below 90%, and the dictionary cache has been tuned, increase the init.ora
parameter DB_CACHE_SIZE to increase the buffer.
13. What is hit ratio?
It is a measure of well the data cache buffer is handling requests for data. It is a percentage of
available and Non-available of data blocks in any memory component to increase performance.
14. What are hints in Oracle? HINTS are nothing but the comments used in a SQL statement to
pass instructions to the Oracle optimizer.The optimizer uses these hints to an execution plan for
the statement.
Database Tuning
3. How do you find the files whose are more than 500k?
fnd . -name "*" -size +500k
5. What does ADDM do?
Oracle10g offers more automatic mechanisms for rudimentary SQL tuning. The AWR tables allow
Oracle10g to collect and maintain detailed SQL execution statistics, and this stored data is then
used by the Advanced Database Diagnostic Monitor (ADDM, pronounced ‘adam’). ADDM attempts
to supply a root cause analysis along with recommendations on what to do to fix the problem. An
ADDM output might contain information that there is read/write contention, a free list problem, or
the need to use locally managed tablespaces.
ADDM can identify high load SQL statements, which can, in turn, be fed into the SQL Tuning
Advisor below. ADDM automatically detects common performance problems, including:
1. Excessive I/O
2. CPU Bottlenecks
3.Contention Issues
4. High Parsing
5.Lock Contention
6.Buffer Sizing Issues
7. RAC Tuning Issues
Creating a new snapshot with information populated in dba_hist_snapshot:
exec dbms_workload_repository.create_snapshot(); The addm_rpt.sql script can be used to view
the output of the snapshot.
6. What is PGA?
A PGA is a memory region that contains data and control information for a server process. It is
nonshared memory created by Oracle Database when a server process is started. Access to
the PGA is exclusive to the server process. There is one PGA for each server process. Background
processes also allocate their own PGAs. The total memory used by all individual PGAs is known as
the total instance PGA memory, and the collection of individual PGAs is referred to as the total
instance PGA, or just instance PGA.
Memory Tuning
1. Who is using which UNDO segment?
Execute the following query to determine who is using a particular UNDO or Rollback Segment:
SQL> SELECT TO_CHAR(s.sid)||','||TO_CHAR(s.serial#) sid_serial,
NVL(s.username, 'None') orauser,s.program,r.name undoseg,t.used_ublk *
TO_NUMBER(x.value)/1024||'K' "Undo" FROM
sys.v_$rollname r,sys.v_$session s,sys.v_$transaction t, sys.v_$parameter x
WHERE s.taddr = t.addr
AND r.usn = t.xidusn(+)
AND x.name = 'db_block_size'
SID_SERIAL ORAUSER PROGRAM UNDOSEG Undo
---------- ---------- ------------------------------ --------------- -------
260,7 SCOTT sqlplus@localhost.localdomain _SYSSMU4$ 8K
(TNS V1-V3)
2. Where can one find the high water mark for a table?
There is no single system table which contains the high water mark (HWM) for a table. A table's
HWM can be calculated using the results from the following SQL statements:
SELECT BLOCKS FROM DBA_SEGMENTS
WHERE OWNER=UPPER(owner) AND SEGMENT_NAME = UPPER(table);
ANALYZE TABLE owner.table ESTIMATE STATISTICS;
SELECT EMPTY_BLOCKS
FROM DBA_TABLES
WHERE OWNER=UPPER(owner) AND TABLE_NAME = UPPER(table);
Thus, the tables' HWM = (query result 1) - (query result 2) - 1
3. Define the SGA?
System Global Area.It consists of Shared pool, Large pool, Java pool, Buffer cache, Log buffer,
Nonstandard block size buffer caches, Keep and recycle buffer caches, and Streams pool.
4. You have 4 instances running on the same UNIX box. How can you determine which shared
memory and semaphores are associated with which instance?Ipcs
SQL> oradebug setmypid
SQL> oradebug ipc
SQL>oradebug tracfile_name
5. When looking at v$sysstat you see that sorts (disk) is high. Is this bad or good? If bad -How do
you correct it? 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.
6. What are SGA_TARGET and SGA_MAX?SGA_Target is the amount SGA that is used by an
instance. If this parameter is set in initialization parameter file then ASMM (Automatic shared
memory management) is done where the buffer cache, Stream pool, Java pool size, Shared pool
size and large pool are managed by Oracle.
SGA_MAX is the Maximum possible size of SGA allowed when you enable ASMM. SGA_MAX cannot
be changed dynamically. If you raise the SGA_target to more that SGA_MAX you will get error.
7. What is different initialization parameters related to tuning?
Some of the parameters that effect performance are DB_CACHE_SIZE,
SGA_MAX,PGA_AGGREGATE_TARGET, SHARED_POOL_SIZE, and SGA_TARGET when you use
ASMM.
8. Name the parts of the database buffer cache.The database buffer cache consists of the keep
buffer cache, recycle buffer cache, and the default buffer cache.The keep buffer cache retains the
data block in memory.The recycle buffer cache removes the buffers from memory when it’s not
needed.The default buffer cache contains the blocks that are not assigned to the other pools
9. Which memory structures are shared? Name two.The library cache contains the shared SQL
areas, private SQL areas, PL/SQL procedures, and packages, and control structures. The large
pool is an optional area in the SGA.
10. What is the maximum number of database writer processes allowed in anOracle instance?
The maximum is 20. Every Oracle instance begins with only one database writer process,
DBW0. Additional writer processes may be started by setting the initialization parameter
DB_WRITER_PROCESSES.
Network Tuning
3. If you want to configure shared servers which three parameters you need to specify in init.ora
file?
LOCAL_LISTENER, SHARED_SERVERS ,DISPATCHERS.
4. What is the function of Dispatcher (Dnnn) ?
Dispatcher (Dnnn) process is responsible for routing requests from connected user processes to
available shared server processes and returning the responses back to the appropriate user
processes
5. How many Dispatcher Processes are created ?At least one Dispatcher process is created for
every communication protocol in use.
Ans: Making optimal use of system using existing resources called performace tuning.
2. Types of Tunings?
Ans: 1. CPU Tuning 2. Memory Tuning 3. IO Tuning 4. Application Tuning 5. Databse Tuning
3. What is an optimizer?
Ans: Optimizer is a mechanizm which will make the execution plan of an sql statement
4. Types of Optimizers?
Ans: CBO
Ans: analyze table emp compute statistics or analyze table emp estimate statistics
Ans: If you use compute, The FTS will happen, if you use estimate just 10% of the table will be
read
10. What wll happen if you set the optimizer_mode=choose?Ans: If the statistics of an object is
available then CBO used. if not RBO will be used
Ans: RBO
17. How do you create a execution plan and how do you see?Ans: 1.
@?/rdbms/admin/utlxplan.sql --------- it creates a plan_table 2. explain set statement_id='1' for
select * from emp; 3. @?/rdbms/admin/utlxpls.sql -------------it display the plan
18. How do you know what sql is currently being used by the session?
Ans: Its a road map how sql is being executed by oracle db?
20. How do you get the index of a table and on which column the index is?
Ans: cursor_sharing=force
Ans: v$librarycache
Ans: v$mystat
3. You see multiple fragments in the SYSTEM tablespace, 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.
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.
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.
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.
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.
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.
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.
11. Describe hit ratio as it pertains to the database buffers. What is the difference between
instantaneous and cumulative hit ratio; which should be used for tuning?
Level: Intermediate
Expected answer: 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 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.
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 may 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.
15. If you see statistics that deal with "undo" what are they really talking about?
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.
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 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.
Unidirectional
Bidirectional
Peer-to-peer
Broadcast
Consolidation
Cascasding
Manager
Extract
Pump
Replicate
Goldengate supports both DML and DDL Replication from the source to target.
What are the supplemental logging pre-requisites?
In the Integrated Capture mode, GoldenGate works directly with the database log mining
server to receive the data changes in the form of logical change records (LCRs).
IC mode does not require any special setup for the databases using ASM, transparent data
encryption, or Oracle RAC.
This feature is only available for oracle databases in Version 11.2.0.3 or higher.
It also supports various object types which were previously not supported by Classic
Capture.
This Capture mode supports extracting data from source databases using compression.
List the minimum parameters that can be used to create the extract process?
The following are the minimium required parameters which must be defined in the extract
parameter file.
EXTRACT NAME
USERID
EXTTRAIL
TABLE
I want to configure multiple extracts to write to the same exttrail file? Is this possible?
Only one Extract process can write to one exttrail at a time. So you can’t configure multiple
extracts to write to the same exttrail.
Network Encryption.
What are the different password encrytion options available with OGG?
You can encrypt the password/data using the AES in three different keys
a) 128 bit
b) 192 bit and
c) 256 bit
Ans:
he Data Pump (not to be confused with the Oracle Export Import Data Pump) is an optional
secondary Extract group that is created on the source system. When Data Pump is not used, the
Extract process writes to a remote trail that is located on the target system using TCP/IP. When
Data Pump is configured, the Extract process writes to a local trail and from here Data Pump will
read the trail and write the data over the network to the remote trail located on the target
system.
The advantages of this can be seen as it protects against a network failure as in the absence of a
storage device on the local system, the Extract process writes data into memory before the same
is sent over the network. Any failures in the network could then cause the Extract process to abort
(abend). Also if we are doing any complex data transformation or filtering, the same can be
performed by the Data Pump. It will also be useful when we are consolidating data from several
sources into one central target where data pump on each individual source system can write to
one common trail file on the target.
ANS:
7809
ANS:
GoldenGate maintains its own Checkpoints which is a known position in the trail file from where
the Replicat process will start processing after any kind of error or shutdown.
This ensures data integrity and a record of these checkpoints is either maintained in files stored
on disk or table in the database which is the preferred option.
ANS:
3. You have written a script to take backups. How do you make it run automatically every week?
corntab
6. How do you see how much hard disk space is free in Linux?
df -lh
7. What is SAR?
The sar command writes to standard output the contents of selected cumulative activity counters
in the operating system
8. What is SHMMAX?
SHMMAX is the maximum size of a shared memory segment on a Linux system
11. How do you see how many memory segments are acquired by Oracle Instances?
sga
pga
Db_buffer_cache
Log_buffer_cache
12. How do you see which segment belongs to which database instances?
13. What is VMSTAT?
vmstat reports information about processes, memory, paging, block IO, traps, and cpu activity.
14. How do you set Kernel Parameters in Red Hat Linux, AIX and Solaris?
There are two methods to configure the Kernel parameters in RHEL
1. by using the command "sysctl -w <parameter_name>= <value>
The above command will change the kernel parameters on the fly but the changes are not
persistent with system reboots. That is why people always choose the second method to make
changes to kernel parameters
2. By editing the file "/etc/sysctl.conf" file
A. Edit the file "/etc/sysctl.conf" by adding the parameters along with values
B. execute "/sbin/sysctl -p" to make sure that the changes are made using the values inside the
above mentioned file.
The advantage with the second method is that the changes are persistent with system reboots.
# touch /etc/init.d/dbora
#!/bin/sh
# chkconfig: 345 99 10
# description: Oracle auto start-stop script.
# Applies to Orcle 10/11g
#
# Set ORA_HOME
# Set ORA_OWNER
ORA_HOME=/u01/app/oracle/product/10.2.0/db_1
ORA_OWNER=oracle
if [ ! -f $ORA_HOME/bin/dbstart ]
then
echo "Oracle startup: Error $ORA_HOME/bin/dbstart doesn't exist, cannot start "
exit
fi
case "$1" in
'start')
# Start the Oracle databases:
# The following command assumes that the oracle login
# will not prompt the user for any values
su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart $ORA_HOME"
touch /var/lock/subsys/dbora
;;
'stop')
# Stop the Oracle databases:
su - $ORA_OWNER -c "$ORA_HOME/bin/dbshut $ORA_HOME"
rm -f /var/lock/subsys/dbora
;;
esac
Edit the “/etc/oratab” file and set the start flag of desired instance to ‘Y’
MYDB1:/u01/app/oracle/product/10.2.0:Y
Q: How do you see how many oracle database instances are running?
2. Q: How do you see how many oracle database instances are running? ::
A: Issue the following command “ps -ef |grep pmon”
[oracle@host ~]$ ps -ef |grep pmon |grep –v grep
oracle 7200 1 0 21:16 ? 00:00:00 ora_pmon_my_db_SID
oracle 9297 9181 0 21:42 pts/0 00:00:00 grep pmon
This will show within the paths returned the names of all instances (if you are OFA compliant –
Oracle Flexible Architecture).
3. Q: You have written a script my_backup.sh to take backups. How do you make it run
automatically every week? ::
The Crontab will do this work.
Crontab commands:
crontab -e (edit user’s crontab)
crontab -l (list user’s crontab)
crontab -r (delete user’s crontab)
crontab -i (prompt before deleting user’s crontab)
Crontab syntax :
crontab entry consists of five fields: day date and time followed by the user (optional) and
command to be executed at the desired time
* * * * * user command to be executed
_ _ _ _ _
| | | | |
| | | | +----- day of week(0-6)the day of the week (Sunday=0)
| | | +------- month (1-12) the month of the year
| | +--------- day of month (1-31) the day of the month
| +----------- hour (0-23) the hour of the day
+------------- min (0-59) the exact minute
#Run automatically every week – every 6th day of a week (Saturday=6)
* * * * 6 root /home/root/scripts/my_backup.sh
#TIP: Crontab script generator:
http://generateit.net/cron-job/
Oerr is an Oracle utility that extracts error messages with suggested actions from the standard
Oracle message files.
Oerr is installed with the Oracle Database software and is located in the ORACLE_HOME/bin
directory.
Example:
"vmstat"
[user@host ~]$ vmstat
procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu----
r b swpd free buff cache si so bi bo in cs us sy id wa
0 0 215560 1281652 250364 754636 0 0 18 15 1 2 3 2 95 0
6. Q How do you see how much hard disk space is free in Linux?::
A: “df” – reports filesystem disk space usage
[user@host ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/lvroot 4.3G 3.3G 723M 2% /
/dev/sda1 104M 14M 85M 14% /boot
none 3.1G 0 3.1G 0% /dev/shm
/dev/mapper/lvtmp 2.2G 209M 1.8G 11% /tmp
/dev/mapper/lvvar 2.2G 267M 1.8G 14% /var
/dev/mapper/lvoracle 38G 11G 26G 31% /u01
TIP: df -h /home (shows disk space usage only for /home)
7. Q: What is SAR?::
Huh It could be anything;
SAR stands for Specific Absorption Rate, which is the unit of measurement for the amount of RF
energy absorbed by the body when using a mobile phone.
SAR is an active remote sensing system; SAR antenna on a satellite that is orbiting the Earth and
so on…
The question should be rather like this: What does sar command do in UNIX/LINUX like systems?
8. Q: What is SHMMAX?::
A: shmmax — maximum size (in bytes) for a UNIX/Linux shared memory segment
DESCRIPTION (docs.hp.com)
Shared memory is an efficient InterProcess Communications (IPC) mechanism.
One process creates a shared memory segment and attaches it to its address space.
Any processes looking to communicate with this process through the shared memory segment,
then attach the shared memory segment to their corresponding address spaces as well.
Once attached, a process can read from or write to the segment depending on the permissions
specified while attaching it.
TIP: To determine the size of the configured swap space in Linux, enter the following command:
To determine the available RAM and swap space use “top” or “free”.
On Solaris systems, Oracle Database uses Intimate Shared Memory (ISM) for shared memory
segments because it shares virtual memory resources between Oracle processes. ISM causes the
physical memory for the entire shared memory segment to be locked automatically.
On Solaris 8 and Solaris 9 systems, dynamic/pageable ISM (DISM) is available. This enables
Oracle Database to share virtual memory resources between processes sharing the segment, and
at the same time, enables memory paging. The operating system does not have to lock down
physical memory for the entire shared memory segment.
Oracle Database automatically selects ISM or DISM based on the following criteriA:
– Oracle Database uses DISM if it is available on the system, and if the value of the
SGA_MAX_SIZE initialization parameter is larger than the size required for all SGA components
combined. This enables Oracle Database to lock only the amount of physical memory that is used.
– Oracle Database uses ISM if the entire shared memory segment is in use at start-up or if the
value of the SGA_MAX_SIZE parameter is equal to or smaller than the size required for all SGA
components combined.
Regardless of whether Oracle Database uses ISM or DISM, it can always exchange the memory
between dynamically sizable components such as the buffer cache, the shared pool, and the large
pool after it starts an instance. Oracle Database can relinquish memory from one dynamic SGA
component and allocate it to another component.
Because shared memory segments are not implicitly locked in memory, when using DISM, Oracle
Database explicitly locks shared memory that is currently in use at start-up. When a dynamic SGA
operation uses more shared memory, Oracle Database explicitly performs a lock operation on the
memory that is put to use. When a dynamic SGA operation releases shared memory, Oracle
Database explicitly performs an unlock operation on the memory that is freed, so that it becomes
available to other applications.
Oracle Database uses the oradism utility to lock and unlock shared memory. The oradism utility is
automatically set up during installation. It is not required to perform any configuration tasks to
use dynamic SGA.
11. Q: How do you see how many memory segments are acquired by Oracle Instances?::
A: ipcs – provides information on the ipc facilities for which the calling process has read acccess
#UNIX: SEGSZ
root> ipcs -pmb
IPC status from <running system> as of Mon Sep 10 13:56:17 EDT 2001
T ID KEY MODE OWNER GROUP SEGSZ CPID
Shared Memory:
m 2400 0xeb595560 --rw-r----- oracle dba 281051136 15130
m 601 0x65421b9c --rw-r----- oracle dba 142311424 15161
#Linux: bytes
[user@host ~]$ icps
------ Shared Memory Segments --------
key shmid owner perms bytes nattch status
0x00000000 32769 oracle 644 122880 2 dest
In case of having multiple instances, grep all trace files for shmid 32769 to identify the database
instance corrsponding to memory segments.
13. Q: What is VMSTAT?::
A: vmstat – Reports virtual memory statistics in Linux environments.
It reports information about processes, memory, paging, block IO, traps, and cpu activity.
[user@host ~]$ vmstat
procs ———–memory———- —swap– —–io—- –system– —-cpu—-
r b swpd free buff cache si so bi bo in cs us sy id wa
3 0 170224 121156 247288 1238460 0 0 18 16 1 0 3 2 95 0
14. Q: How do you set Kernel Parameters in Red Hat Linux, AIX and Solaris?::
A: sysctl – configure kernel parameters at runtime
EXAMPLES
/sbin/sysctl -a (Display all values currently available)
/sbin/sysctl -w kernel.shmmax = 3058759680 ( -w this option changes a sysctl setting)
To modify settings permanetly edit /etc/sysctl – kernel sysctl configuration file and then issue the
following command:
/sbin/sysctl -p /etc/sysctl.conf ( Load in sysctl settings from the file specified or /etc/sysctl.conf if
none given)
First kill all Oracle database processes; A shared memory object is only removed after all currently
attached processes have detached.
#UNIX
root> ps -ef | grep $ORACLE_SID | grep -v grep | awk '{print $2}' | xargs -i kill -9 {}
root> ipcs -pmb #displays held memory
IPC status from /dev/kmem as of Tue Sep 30 11:11:11 2011
T ID KEY MODE OWNER GROUP SEGSZ CPID LPID
Shared Memory:
m 25069 0x4e00e002 –rw-r—– oracle dba 35562418 2869 23869
m 1 0x4bc0eb18 –rw-rw-rw- root root 31008 669 669
root> ipcrm –m 25069 #this command will release that memory segment
ln – makes links between files. By default, it makes hard links; with the “-s” option, it makes
symbolic (soft) links.
Synopses:
ln [OPTION]… TARGET [LINKNAME]
ln [OPTION]… TARGET… DIRECTORY
EXAMPLE:
#hard links
[user@host ~]$ touch file1
[user@host ~]$ ln file1 file2
[user@host ~]$ ls -li
total 0
459322 -rw-r--r-- 2 userxxx users 0 May 6 16:19 file1
459322 -rw-r--r-- 2 userxxx users 0 May 6 16:19 file2 (the same inode, rights, size, time and so
on!)
[user@host ~]$ mkdir dir1
[user@host ~]$ ln dir1 dir2
ln: `dir1′: hard link not allowed for directory
#symbolic links
[user@host ~]$ rm file2 #hard link removed
[user@host ~]$ ln -s file1 file2 #symlink to file
[user@host ~]$ ln -s dir1 dir2 #symlink to directory
[user@host ~]$ ls -li
total 12
459326 drwxr-xr-x 2 userxxx users 4096 May 6 16:38 dir1
459327 lrwxrwxrwx 1 userxxx users 4 May 6 16:39 dir2 -> dir1 (dir2 refers to dir1)
459322 -rw-r–r– 1 userxxx users 0 May 6 16:19 file1
459325 lrwxrwxrwx 1 userxxx users 5 May 6 16:20 file2 -> file1 (different inode, rights, size
and so on!)
[user@host ~]$ rm file2 #will remove a symlink NOT a targed file; file1
[user@host ~]$ rm dir2
[user@host ~]$ ls -li
[user@host ~]$ ls -li
total 4
459326 drwxr-xr-x 2 userxxx users 4096 May 6 16:38 dir1
459322 -rw-r–r– 1 userxxx users 0 May 6 16:19 file1
[user@host ~]$ info coreutils ln #(should give you access to the complete manual)
EXAMPLES:
[user@host ~]$ cat /etc/oratab
MYDB1:/u01/app/oracle/product/10.2.0/db:Y
emagent:/u01/app/oracle/product/oem/agent10g:N
client:/u01/app/oracle/product/10.2.0/client_1:N
emcli:/u01/app/oracle/product/oem/emcli:N
DB Creation
V$SGA
V$INSTANCE
V$DATABASE
V$PROCESS
V$SYSAUX_OCCUPANTS
TBS Management
DBA_TABLESPACES
DBA_TABLESPACE_GROUPS
DBA_DATA_FILES
DBA_FREE_SPACE
V$TABLESPACE
V$DATAFILE
DATABASEE_PROPERTIES
Roles & Privileges
ALL_COL_PRIVS
USER_COL_PRIVS
ALL_TAB_PRIVS
USER_TAB_PRIVS
ALL_TAB_PRIVS_MADE
USER_TAB_PRIVS_MADE
ALL_TAB_PRIVS_RECD
USER_TAB_PRIVS_RECD
DBA_ROLES
DBA_COL_PRIVS
USER_ROLE_PRIVS
DBA_ROLE_PRIVS
USER_SYS_PRIVS
DBA_SYS_PRIVS
COLUMN_PRIVILEGES
DBA_TAB_PRIVS
ROLE_ROLE_PRIVS
ROLE_SYS_PRIVS
SESSION_PRIVS
SESSION_ROLES
Control Files
V$CONTROLFILE
V$CONTROLFILE_RECORD_SECTION
Storage Parameters
DBA_SEGMENTS
DBA_EXTENTS
DBA_TABLES
DBA_INDEXES
DBA_TABLESPACES
DBA_DATA_FILES
DBA_FREE_SPACE
Auditing
STMT_AUDIT_OPTION_MAP
AUDIT_ACTIONS
ALL_DEF_AUDIT_OPTS
DBA_STMT_AUDIT_OPTS
USER_OBJ_AUDIT_OPTS
DBA_OBJ_AUDIT_OPTS
USER_AUDIT_TRAIL
DBA_AUDIT_TRAIL
USER_AUDIT_SESSION
DBA_AUDIT_STATEMENT
USER_AUDIT_OBJECT
DBA_AUDIT_OBJECT
DBA_AUDIT_EXISTS
USER_AUDIT_SESSIONS
DBA_AUDIT_SESSION
USER_TAB_AUDIT_OPTS
Rollback Segments
DBA_SEGMENTS
USER_SEGMENTS
DBA_ROLLBACK_SEGS
V$ROLLSTAT
V$ROLLNAME
Data PUMP
DBA_DATAPUMP_JOBS
USER_DATAPUMP_JOBS
DBA_DIRECTORIES
Dispatchers
V$DISPATCHER_CONFIG
V$MTS
V$DISPATCHER
Security
DBA_USERS
DBA_USERS_WITH_DEFPWD
Undo Management
DBA_UNDO_EXTENTS
DBA_SEGMENTS
USER_SEGMENTS
V$UNDOSTAT
U$TRANSACTION
Tuning
V$PX_PROCESS
V$PX_SESSION
V$PX_PROCESS_SYSSTAT
1. Basic (Every DBA should answer correctly ALL these questions. This knowledge is just basic for
a 3+ year experienced DBA)
1.1 Q- Which are the default passwords of SYSTEM/SYS?
A- MANAGER / CHANGE_ON_INSTALL
1.2 Q- How can you execute a script file in SQLPLUS?
A- To execute a script file in SQLPlus, type @ and then the file name.
1.3 Q- Where can you find official Oracle documentation?
A- tahiti.oracle.com
1.4 Q- What is the address of the Official Oracle Support?
A- metalink.oracle.com or support.oracle.com
1.5 Q- What file will you use to establish Oracle connections from a remote client?
A- tnsnames.ora
1.6 Q- How can you check if the database is accepting connections?
A- lsnrctl status or lsnrctl services
1.7 Q- Which log would you check if a database has a problem?
A- Alert log
1.8 Q- Name three clients to connect with Oracle, for example, SQL Developer:
A- SQL Developer, SQL-Plus, TOAD, dbvisualizer, PL/SQL Developer… There are several, but an
experienced dba should know at least three clients.
1.9 Q- How can you check the structure of a table from sqlplus?
A- DESCRIBE or DESC
1.10 Q- What command will you start to run the installation of Oracle software on Linux?
A- runInstaller
2. Moderate (Standard knoledge for a daily-work of every DBA. He could fail one or two questions,
but not more)
2.1 Q- What should you do if you encounter an ORA-600?
A- Contact Oracle Support
2.2 Q- Explain the differences between PFILE and SPFILE
A- A PFILE is a Static, text file that initialices the database parameter in the moment that it’s
started. If you want to modify parameters in PFILE, you have to restart the database.
A SPFILE is a dynamic, binary file that allows you to overwrite parameters while the database is
already started (with some exceptions)
2.3 Q- In which Oracle version was Data Pump introduced?
A- Oracle 10g
2.4 Q- Say two examples of DML, two of DCL and two of DDL
A- DML: SELECT, INSERT, UPDATE, DELETE, MERGE, CALL, EXPLAIN PLAN, LOCK TABLE
DDL: CREATE, ALTER, DROP, TRUNCATE, COMMENT, RENAME
DCL: GRANT, REVOKE
2.5 Q- You want to save the output of an Oracle script from sqlplus. How would you do it?
A- spool script_name.txt
select * from your_oracle_operations;
spool off;
2.6 Q- What is the most important requirement in order to use RMAN to make consistent hot
backups?
A- Your database has to be in ARCHIVELOG mode.
2.7 Q- Can you connect to a local database without a listener?
A- Yes, you can.
2.8 Q- In which view can you find information about every view and table of oracle dictionary?
A- DICT or DICTIONARY
2.9 Q- How can you view all the users account in the database?
A- SELECT USERNAME FROM DBA_USERS;
2.10 Q- In linux, how can we change which databases are started during a reboot?
A- Edit /etc/oratab
3. Advanced (A 3+ year experienced DBA should have enough knowledge to answer these
questions. However, depending on the work he has done, he could still fail up to 4 questions)
3.1 Q- When a user process fails, what Oracle background process will clean after it?
A- PMON
3.2 Q- How can you reduce the space of TEMP datafile?
A- Prior to Oracle 11g, you had to recreate the datafile. In Oracle 11g a new feature was
introduced, and you can shrink the TEMP tablespace.
3.3 Q- How can you view all the current users connected in your database in this moment?
A- SELECT COUNT(*),USERNAME FROM V$SESSION GROUP BY USERNAME;
3.4 Q- Explain the differences between SHUTDOWN, SHUTDOWN NORMAL, SHUTDOWN
IMMEDIATE AND SHUTDOWN ABORT
A- SHUTOWN NORMAL = SHUTDOWN : It waits for all sessions to end, without allowing new
connections.
SHUTDOWN IMMEDIATE : Rollback current transactions and terminates every session.
SHUTDOWN ABORT : Aborts all the sessions, leaving the database in an inconsistent state. It’s
the fastest method, but can lead to database corruption.
3.5 Q- Is it possible to backup your database without the use of an RMAN database to store the
catalog?
A- Yes, but the catalog would be stored in the controlfile.
3.6 Q- Which are the main components of Oracle Grid Control?
A- OMR (Oracle Management Repository), OMS (Oracle Management Server) and OMA (Oracle
Management Agent).
3.7 Q- What command will you use to navigate through ASM files?
A- asmcmd
3.8 Q- What is the difference between a view and a materialized view?
A- A view is a select that is executed each time an user accesses to it. A materialized view stores
the result of this query in memory for faster access purposes.
3.9 Q- Which one is faster: DELETE or TRUNCATE?
A- TRUNCATE
3.10 Q- Are passwords in oracle case sensitive?
A- Only since Oracle 11g.
4. RAC (Only intended for RAC-specific DBAs, with varied difficultied questions)
4.1 Q- What is the recommended method to make backups of a RAC environment?
A- RMAN to make backups of the database, dd to backup your voting disk and hard copies of the
OCR file.
4.2 Q- What command would you use to check the availability of the RAC system?
A- crs_stat -t -v (-t -v are optional)
4.3 Q- What is the minimum number of instances you need to have in order to create a RAC?
A- 1. You can create a RAC with just one server.
4.4 Q- Name two specific RAC background processes
A- RAC processes are: LMON, LMDx, LMSn, LKCx and DIAG.
4.5 Q- Can you have many database versions in the same RAC?
A- Yes, but Clusterware version must be greater than the greater database version.
4.6 Q- What was RAC previous name before it was called RAC?
A- OPS: Oracle Parallel Server
4.7 Q- What RAC component is used for communication between instances?
A- Private Interconnect.
4.8 Q- What is the difference between normal views and RAC views?
A- RAC views has the prefix ‘G’. For example, GV$SESSION instead of V$SESSION
4.9 Q- Which command will we use to manage (stop, start…) RAC services in command-line
mode?
A- srvctl
4.10 Q- How many alert logs exist in a RAC environment?
A- One for each instance.
5. Master (A 3+ year experienced DBA would probably fail these questions, they are very specifid
and specially difficult. Be glad if he’s able to answer some of them)
5.1 Q- How can you difference a usual parameter and an undocumented parameter?
A- Undocumented parameters have the prefix ‘_’. For example, _allow_resetlogs_corruption
5.2 Q- What is BBED?
A- An undocumented Oracle tool used for foresnic purposes. Stans for Block Browser and EDitor.
5.3 Q- The result of the logical comparison (NULL = NULL) will be… And in the case of (NULL !=
NULL)
A- False in both cases.
5.4 Q- Explain Oracle memory structure
The Oracle RDBMS creates and uses storage on the computer hard disk and in random access
memory (RAM). The portion in the computer s RAM is called memory structure. Oracle has two
memory structures in the computer s RAM. The two structures are the Program Global Area (PGA)
and the System Global Area (SGA).
The PGA contains data and control information for a single user process. The SGA is the memory
segment that stores data that the user has retrieved from the database or data that the user
wants to place into the database.
5.5 Q- Will RMAN take backups of read-only tablespaces?
A- No
5.6 Q- Will a user be able to modify a table with SELECT only privilege?
A- He won’t be able to UPDATE/INSERT into that table, but for some reason, he will still be able to
lock a certain table.
5.7 Q- What Oracle tool will you use to transform datafiles into text files?
A- Trick question: you can’t do that, at least with any Oracle tool. A very experienced DBA should
perfectly know this.
5.8 Q- SQL> SELECT * FROM MY_SCHEMA.MY_TABLE;
SP2-0678: Column or attribute type can not be displayed by SQL*Plus
Why I’m getting this error?
A- The table has a BLOB column.
5.9 Q- What parameter will you use to force the starting of your database with a corrupted
resetlog?
A- _ALLOW_RESETLOGS_CORRUPTION
5.10 Q- Name the seven types of Oracle tables
A- Heap Organized Tables, Index Organized Tables, Index Clustered Tables, Hash Clustered
Tables, Nested Tables, Global Temporary Tables, Object Tables.
Oracle 11g and 12c New features
Oracle 11g Database New Features Interview Questions and Answers
1. Database Replay
2. The SQL Performance Analyzer
3. Online Patching in Oracle Database Control
4. Automatic Diagnostic Repository (ADR)
5. Data Recovery Advisor
6. Automatic Memory Management
7. Invisible Indexes
8. Read-Only Tables
9. Shrinking Temporary Tablespaces and Tempfiles
10. Server Result Cache
11. SQL Tuning Automation
12. SQL Plan Management
13. Database ADDM
14. New SYSASM Privilege for ASM Administration
15. Enhanced Block Media Recovery
16. VALIDATE Command
17. Configuring an Archived Redo Log Deletion Policy
18. Active Database Duplication
19. Virtual Private Catalogs
20. ASM Restricted Mode
21. Checking Diskgroup
22. The FORCE option with Drop Diskgroup Command
23. Active Data Guard is a new option for Oracle Database 11g Enterprise Edition
Database Replay
Database Replay (sometimes named as Workload Replay) feature in Oracle11g allows you to
reproduce the
production database conditions in a testing environment.In other words, with this feature you can
capture the
actual workload on a production system and replay it in a test system. This way, you can analyze
the condition of the production database without working on the actual production database.
This feature enables you to test the impact of applying changes on a production database. These
changes could be database upgrades, switching to RAC, application upgrades, operating system
upgrades or storage system changes.
This is very useful for a DBA to analyze how a change on the database (including database
upgrade) may affect the execution efficiency of SQL statements. Using this tool is explained here
because you may consider using it to study the effect of upgrading an Oracle database 10g
release 2 to 11g.
Note:
If you plan to use SPA on a test database, it is highly recommended to make the test database
resemble the production database as closely as possible. You can use the RMAN duplicate
command for this purpose.
In UNIX systems, you use the script $ORACLE_HOME/OPatch/opatch to invoke the online
patching.
In Oracle 11g, there is a new framework (named as fault diagnosability infrastructure) consisting
of many tools for diagnosing and repairing the errors in the database. All those tools refer to the
ADR in their operation.
Note:
For each database instance two alert log files are generated: one as text file and one with xml
format. Contents of the xml-formatted file can be examined using adrci tool.
Also the xml-formatted alert log is saved in the ADR and specifically in the directory
$ORACLE_BASE/diag/rdbms/$INSTANCE_NAME/$ORACLE_SID/alert
The advisor however doe not recover from failures on standby databases or RAC environment.
This advisor can be used through RMAN or the Enterprise Manager.
This parameter is dynamic and can be alter using the ALTER SYSTEM command as shown below:
ALTER SYSTEM SET MEMORY_TARGET = 1024M ;
However, if the database is not configured to use this parameter and you want to use it, you must
restart the
database after setting the parameter.
Invisible Indexes
Invisible index is an index that is not considered by the optimizer when creating the execution
plans. This can be used to test the effect of adding an index to a table on a query (using index
hint) without actually being used by the other queries.
Read-Only Tables
In Oracle 11g, you can set a table to be read only,i.e. users can only query from the table but no
DML
statement is allowed on the table.
Shrinking Temporary Tablespaces and Tempfiles
In Oracle 11g, you can shrink temporary tablespaces and tempfiles.
As clear from its concept, result cache is mostly useful in for frequently executed queries with rare
changes on the retrieved data.
The advisor also may recommend actions like creating new indexes, refreshing statistics or re-
writing the statement. These actions, however, are not automatically implemented by the
advisor.
To use the DBMS_AUTO_SQLTUNE package, you must have the DBA role, or have EXECUTE
privileges granted by an administrator. The only exception is the EXECUTE_AUTO_TUNING_TASK
procedure, which can only be run by SYS.
When SPM is enabled, the system maintains a plan history that contains all plans generated by
the optimizer and store them in a component called plan baseline. Among the plan history in the
plan baseline, plans that are verified not to cause performance regression are marked as
acceptable. The plan baseline is used by the optimizer to decide on the best plan to use when
compiling a SQL statement.
Repository stored in data dictionary of plan baselines and statement log maintained by the
optimizer is called
SQL management base(SMB).
While the block media recovery is going on, any attempt by users to access data in the corrupt
blocks will result in an error message, telling the user that the data block is corrupt.
VALIDATE Command
You can use the new command VALIDATE to manually check for physical and logical corruptions in
datafiles,backup sets, and even individual data blocks. The comma nd by default checks for
physical corruption. You can optionally specify CHECK LOGICAL . Corrupted blocks are reported in
V$DATABASE_BLOCK_CORRUPTION.
To enable an archived redo log deletion policy, run the CONFIGURE ARCHIVELOG DELETION
POLICY BACKED UP n TIMES command with the desired options.
In Oracle 11g, you can start the ASM instance in restricted mode. When in restricted mode,
databases will not be permitted to access the ASM instance. Also, individual diskgroup can be set
in restricted mode.
Checking Diskgroup
Starting from Oracle Database 11g, you can validate the internal consistency of ASM diskgroup
metadata using the ALTER DISKGROUP ... CHECK command. Summary of errors is logged in the
ASM alert log file.
If a disk is destroyed beyond repair, you want to drop it. But because the disk is practically
damaged, you cannot mount it and thus you cannot issue the DROP DISKGROUP command
against it. In such a condition, Oracle 11g provides the FORCE INCLUDING CONTENTS option to
drop the diskgroup even if it is not mounted.
Active Data Guard is a new option for Oracle Database 11g Enterprise Edition
An Active Data Guard standby database is an exact copy of the primary that is open read-only
while it continuously applies changes transmitted by the primary database. An active standby can
offload ad-hoc queries, reporting, and fast incremental backups from the primary database,
improving performance and scalability while preventing data loss or downtime due to data
corruptions, database and site failures, human error, or natural disaster. Oracle Active Data
Guard enables read-only access to a physical standby database.
With Oracle Active Data Guard, a physical standby database can be used for real-time reporting,
with minimal latency between reporting and production data. Compared with traditional replication
methods, Active Data Guard is very simple to use, transparently supports all datatypes, and offers
very high performance. Oracle Active Data Guard also allows backup operations to be off-loaded
to the standby database, and be done very fast using intelligent incremental backups.
1. What is Assm?
Automatic segment space management (ASSM) is a simpler and more efficient way of managing
space within a segment. It completely eliminates any need to specify and tune the pctused,
freelists, and freelist groups’ storage parameters for schema objects created in the tablespace. If
any of these attributes are specified, they are ignored.
2. What is Asmm?
ASMM (Automatic Shared Memory Management) is the collective name for the dynamic memory
allocation technologies added in Oracle 9i and improved with each subsequent release. This
reduces the amount of manual configuration required and allows the database to adapt to
workload changes.
•Upgraded
•Patched
•Monitored
•Tuned
•RAC Enabled
•Adjusted
•Backed up and
•Data Guarded.
With Pluggable Databases feature, you just have to do all this for ONE single instance. Without
this feature, prior to 12C, you would have to create separate schemas and there is always a
thread of security how much ever the isolation we build into it. There are problems with
namespace conflicts, there is always going to be one public synonym that you can create. With
PDBs you can have a separate HR or Scott schema for each PDB, separate Emp, Dept Tables and
separate public synonyms. Additionally, 2 PDBs can talk to each other through the regular DB Link
feature. There is no high startup cost of creating a database any more. Instead of one instance
per day, the shift is into one instance per many databases. For the developer community, you can
be oblivious of all this and still continue to use the PDBs as if it were a traditional database, but
for the DBAs the world would look like it has changed a lot.
Another cool feature is, you can allocate a CPU percentage for each PDB.
Another initiative being, it has announced a strategic tieup with salesforce.com during the first
week of July 2013.