Tuesday, 29 October 2013

Oracle Interview Questions 09



101. Will the Optimizer always use COST-based approach if OPTIMIZER_MODE is set to "Cost'?
Presence of statistics in the data dictionary for atleast one of the tables accessed by the SQL statements is necessary for the OPTIMIZER to use COST-based approach. Otherwise OPTIMIZER chooses RULE-based approach.

102. What is the effect of setting the value of OPTIMIZER_MODE to 'RULE' ?
This value causes the optimizer to choose the rule_based approach for all SQL statements issued to the instance regardless of the presence of statistics.

103. What are the values that can be specified for OPTIMIZER_GOAL parameter of the ALTER SESSION Command ?
CHOOSE,ALL_ROWS,FIRST_ROWS and RULE.

104. What is the effect of setting the value "CHOOSE" for OPTIMIZER_GOAL, parameter of the ALTER SESSION Command ?
The Optimizer chooses Cost_based approach and optimizes with the goal of best throughput if statistics for atleast one of the tables accessed by the SQL statement exist in the data dictionary. Otherwise the OPTIMIZER chooses RULE_based approach.

105. What is the effect of setting the value "ALL_ROWS" for OPTIMIZER_GOAL parameter of the ALTER SESSION command ?
This value causes the optimizer to the cost-based approach for all SQL statements in the session regardless of the presence of statistics and to optimize with a goal of best throughput.

106. What is the effect of setting the value 'FIRST_ROWS' for OPTIMIZER_GOAL parameter of the ALTER SESSION command ?
This value causes the optimizer to use the cost-based approach for all SQL statements in the session regardless of the presence of statistics and to optimize with a goal of best response time.

107. What is the effect of setting the 'RULE' for OPTIMIER_GOAL parameter of the ALTER SESSION Command ?
This value causes the optimizer to choose the rule-based approach for all SQL statements in a session regardless of the presence of statistics.

108. What is RULE-based approach to optimization ?
Choosing an executing planbased on the access paths available and the ranks of these access paths.

109. 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.


PROGRAMMATIC CONSTRUCTS

110. What are the different types of PL/SQL program units that can be defined and stored in ORACLE database ?
Procedures and Functions,Packages and Database Triggers.

111. What is a Procedure ?
A Procedure consist of a set of SQL and PL/SQL statements that are grouped together as a unit to solve a specific problem or perform a set of related tasks.

112. What is difference between Procedures and Functions ?
A Function returns a value to the caller where as a Procedure does not.

113. What is a Package ?
A Package is a collection of related procedures, functions, variables and other package constructs together as a unit in the database.

114. What are the advantages of having a Package ?
Increased functionality (for example,global package variables can be declared and used by any proecdure in the package) and performance (for example all objects of the package are parsed compiled, and loaded into memory once)

115. What is Database Trigger ?
A Database Trigger is procedure (set of SQL and PL/SQL statements) that is automatically executed as a result of an insert in,update to, or delete from a table.

116. What are the uses of Database Trigger ?
Database triggers can be used to automatic data generation, audit data modifications, enforce complex Integrity constraints, and customize complex security authorizations.

117. What are the differences between Database Trigger and Integrity constraints ?
A declarative integrity constraint is a statement about the database that is always true. A constraint applies to existing data in the table and any statement that manipulates the table.
A trigger does not apply to data loaded before the definition of the trigger, therefore, it does not guarantee all data in a table conforms to the rules established by an associated trigger.
A trigger can be used to enforce transitional constraints where as a declarative integrity constraint cannot be used.

DATABASE SECURITY

118. What are Roles ?
Roles are named groups of related privileges that are granted to users or other roles.

119. What are 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.
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.

120. How to prevent unauthorized use of privileges granted to a Role ?
By creating a Role with a password.

121. What is default tablespace ?
The Tablespace to contain schema objects created without specifying a tablespace name.

122. What is Tablespace Quota ?
The collective amount of disk space available to the objects in a schema on a particular tablespace.

123. What is a profile ?
Each database user is assigned a Profile that specifies limitations on various system resources available to the user.

124. What are the system resources that can be controlled through Profile ?
The number of concurrent sessions the user can establish the CPU processing time available to the user's session the CPU processing time available to a single call to ORACLE made by a SQL statement the amount of logical I/O available to the user's session the amout of logical I/O available to a single call to ORACLE made by a SQL statement the allowed amount of idle time for the user's session the allowed amount of connect time for the user's session.

125. What is Auditing ?
Monitoring of user access to aid in the investigation of database use.

126. What are the different Levels of Auditing ?
Statement Auditing, Privilege Auditing and Object Auditing.

127. What is Statement Auditing ?
Statement auditing is the auditing of the powerful system privileges without regard to specifically named objects.

128. What is Privilege Auditing ?
Privilege auditing is the auditing of the use of powerful system privileges without regard to specifically named objects.

129. What is Object Auditing ?
Object auditing is the auditing of accesses to specific schema objects without regard to user.

DISTRIBUTED PROCESSING AND DISTRIBUTED DATABASES

130. What is Distributed database ?
A distributed database is a network of databases managed by multiple database servers that appears to a user as single logical database. The data of all databases in the distributed database can be simultaneously accessed and modified.

131. What is Two-Phase Commit ?
Two-phase commit is mechanism that guarantees a distributed transaction either commits on all involved nodes or rolls back on all involved nodes to maintain data consistency across the global distributed database. It has two phase, a Prepare Phase and a Commit Phase.

132. Describe two phases of Two-phase commit ?
Prepare phase - The global coordinator (initiating node) ask a participants to prepare (to promise to commit or rollback the transaction, even if there is a failure)
Commit - Phase - If all participants respond to the coordinator that they are prepared, the coordinator asks all nodes to commit the transaction, if all participants cannot prepare, the coordinator asks all nodes to roll back the transaction.

133. What is the mechanism provided by ORACLE for table replication ?
Snapshots and SNAPSHOT LOGs

134. What is a SNAPSHOT ?
Snapshots are read-only copies of a master table located on a remote node which is periodically refreshed to reflect changes made to the master table.

135. What is a SNAPSHOT LOG ?
A snapshot log is a table in the master database that is associated with the master table. ORACLE uses a snapshot log to track the rows that have been updated in the master table. Snapshot logs are used in updating the snapshots based on the master table.

136. What is a SQL * NET?
SQL *NET is ORACLE's mechanism for interfacing with the communication protocols used by the networks that facilitate distributed processing and distributed databases. It is used in Clint-Server and Server-Server communications.

DATABASE OPERATION, BACKUP AND RECOVERY

137. What are the steps involved in Database Startup ?
Start an instance, Mount the Database and Open the Database.

138. What are the steps involved in Database Shutdown ?
Close the Database, Dismount the Database and Shutdown the Instance.

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

140. 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.

141. What is Full Backup ?
A full backup is an operating system backup of all data files, on-line redo log files and control file that constitute ORACLE database and the parameter.

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

143. 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.

144.WhatisOn-lineRedoLog?
The On-line Redo Log is a set of tow or more on-line redo files that record all committed changes made to the database. Whenever a transaction is committed, the corresponding redo entries temporarily stores in redo log buffers of the SGA are written to an on-line redo log file by the background process LGWR. The on-line redo log files are used in cyclical fashion.

145. What is Mirrored on-line Redo Log ?
A mirrored on-line redo log consists of copies of on-line redo log files physically located on separate disks, changes made to one member of the group are made to all members.

146. What is Archived Redo Log ?
Archived Redo Log consists of Redo Log files that have archived before being reused.

147. 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.

148. What is Log Switch ?
The point at which ORACLE ends writing to one online redo log file and begins writing to another is called a log switch.

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

No comments:

Post a Comment