Oracle Database – Technical Questions Answers

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


  • What is On-line Redo Log? – 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.


  • Which parameter specified in the DEFAULT STORAGE clause of CREATE TABLESPACE cannot be altered after creating the tablespace? – All the default storage parameters defined for the tablespace can be changed using the ALTER TABLESPACE command. When objects are created their INITIAL and MINEXTENS values cannot be changed.


  • What are the steps involved in Database Startup? – Start an instance, Mount the Database andOpen the Database.


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


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


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


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


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


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


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


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


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


  • Can a View based on another View? – Yes.


  • Can a Tablespace hold objects from different Schemes? – Yes.


  • Can objects of the same Schema reside in different tablespaces? – Yes.


  • What is the use of Control File? – When an instance of an ORACLE database is started, its control file is used to identify the database and redo log files that must be opened for database operation to proceed. It is also used in database recovery.


  • Do View contain Data? – Views do not contain or store data.


  • What are the Referential actions supported by FOREIGN KEY integrity constraint? – UPDATE and DELETE Restrict – A referential integrity rule that disallows the update or deletion of referenced data. DELETE Cascade – When a referenced row is deleted all associated dependent rows are deleted.


  • What are the type of Synonyms? – There are two types of Synonyms Private and Public


  • What is a Redo Log? – The set of Redo Log files YSDATE,UID,USER or USERENV SQL functions, or the pseudo columns LEVEL or ROWNUM.


  • What is an Index Segment? – Each Index has an Index segment that stores all of its data.


  • 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


  • What are the different type of Segments? – Data Segment, Index Segment, Rollback Segment and Temporary Segment.


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


  • What is an Integrity Constrains? – An integrity constraint is a declarative way to define a business rule for a column of a table.


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


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


  • What is a View? – A view is a virtual table. Every view has a Query attached to it. (The Query is a SELECT statement that identifies the columns and rows of the table(s) the view uses.)


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


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


  • What is a Sequence? – A sequence generates a serial list of unique numbers for numerical columns of a database’s tables.


  • What is a Segment? – A segment is a set of extents allocated for a certain logical structure.


  • What is schema? – A schema is collection of database objects of a User.


  • Describe Referential Integrity? – A rule defined on a column (or set of columns) in one table that allows the insert or update of a row only if the value for the column or set of columns (the dependent value) matches a value in a column of a related table (the referenced value). It also specifies the type of data manipulation allowed on referenced data and the action to be performed on dependent data as a result of any action on referenced data.


  • What is Hash Cluster? – A row is stored in a hash cluster based on the result of applying a hash function to the row’s cluster key value. All rows with the same hash key value are stores together on disk.


  • What is a Private Synonyms? – A Private Synonyms can be accessed only by the owner.


  • What is Database Link? – A database link is a named object that describes a “path” from one database to another.


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


  • What is Rollback Segment? – A Database contains one or more Rollback Segments to temporarily store “undo” information.


  • What are the Characteristics of Data Files? – A data file can be associated with only one database. Once created a data file can’t change size. One or more data files form a logical unit of database storage called a tablespace.


  • How to define Data Block size? – A data block size is specified for each ORACLE database when the database is created. A database users and allocated free database space in ORACLE datablocks. Block size is specified in INIT.ORA file and can’t be changed latter.


  • What does a Control file Contain? – A Control file records the physical structure of the database. It contains the following information. Database Name Names and locations of a database’s files and redolog files. Time stamp of database creation.


  • What is difference between UNIQUE constraint and PRIMARY KEY constraint? – A column defined as UNIQUE can contain Nulls while a column defined as PRIMARY KEY can’t contain Nulls. 47.What is Index Cluster? – A Cluster with an index on the Cluster Key 48.When does a Transaction end? – When it is committed or Rollbacked.


  • What is the effect of setting the value “ALL_ROWS” for OPTIMIZER_GOAL parameter of the ALTER SESSION command? – What are the factors that affect OPTIMIZER in choosing an Optimization approach? – Answer The OPTIMIZER_MODE initialization parameter Statistics in the Data Dictionary the OPTIMIZER_GOAL parameter of the ALTER SESSION command hints in the statement.


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


  • What is the function of Optimizer? – The goal of the optimizer is to choose the most efficient way to execute a SQL statement.


  • What is Execution Plan? – The combinations of the steps the optimizer chooses to execute a statement is called an execution plan.


  • What are the different approaches used by Optimizer in choosing an execution plan? – Rule-based and Cost-based.

Oracle Database related Questions

Here there are very basic still sometime become critical to know concept if you working in Oracle Database related activities. 

Q: What is an Oracle instance?Every running Oracle database is associated with an Oracle instance. When adatabase is started on a database server (regardless of the type of computer),Oracle allocates a memory area called the System Global Area (SGA) and starts one or more Oracle processes. This combination of the SGA and the Oracle processes is called an Oracle instance. The memory and processes of an instance manage the associated database’s data efficiently and serve the one or multiple users of the database.
The Instance and the Database

After starting an instance, Oracle associates the instance with the specified database. This is called mounting the database. The database is then ready to be opened, which makes it accessible to authorized users. Multiple instances can execute concurrently on the same computer, each accessing its own physical database. In clustered and massively parallel systems (MPP),the Oracle Parallel Server allows multiple instances to mount a single database. Only the database administrator can start up an instance and open the database.If a database is open, the database administrator can shut down the database so that it is closed. When a database is closed, users cannot access the information that it contains. Security for database startup and shutdown is controlled via connections to Oracle with administrator privileges. Normal users do not have control over the current status of an Oracle database.




Q: What is a view?

A view is a tailored presentation of the data contained in one or more tables(or other views). Unlike a table, a view is not allocated any storage space, nor does a view actually contain data; rather, a view is defined by a query that extracts or derives data from the tables the view references. These tables are called base tables. Views present a different representation of the data that resides within thebase tables. Views are very powerful because they allow you to tailor the presentation of data to different types of users. Views are often used to:

• provide an additional level of table security by restricting access to a predetermined set of rows and/or columns of a table

• hide data complexity

• simplify commands for the user

• present the data in a different perspective from that of the base table

• isolate applications from changes in definitions of base tables

• express a query that cannot be expressed without using a view

Q: What is referential integrity?


Rules governing the relationships between primary keys and foreign keys of tables within a relational database that determine data consistency. Referential integrity requires that the value of every foreign key in every table be matched by the value of a primary key in another table.

Q: What is a cursor?A cursor is a private sql work area used to perform manipulations on data using pl\sql, mainly used for multiple row manipulations and locking columns. Data which is populated into the cursor is known as active dataset.


Cursors are of two types 1.implicit   2.explicit

Implicit———attributes or properties for implicit cursor

1.sql%is open:attribute returns a boolean value stating wether the cursor is open or closed.

2.sql % found: returns boolean value stating whether the record is found in the cursor.

3.sql%notfound : returns a boolean value stating whether the record is not found in the cursor

4.sql %rowcount :returns a pneumeric value stating no.of rows executed in the cursor.

Explicit cursors—retrives multiple rows, users can perform locks on th data in the cursor attributes-

1.% is open

2.% found

3.% not found

4.% rowcount




Q: Why Use Sql* Loader in Oracle Database? 
The Sql Loader utility loads data into an existing ORACLE table from an external files.



Oracle Technical – Improve Import/ Export performance?



Ø       Set the BUFFER parameter to a high value (e.g. 2M)



Ø       Set the RECORDLENGTH parameter to a high value (e.g. 64K)

Ø       Stop unnecessary applications to free-up resources for your job.

Ø       If you run multiple export sessions, ensure they write to different physical disks.

Ø       DO NOT exports to an NFS mount filesystem. It will take forever.



Ø       Create an indexfile so that you can create indexes AFTER you have imported data. Do this by setting INDEXFILE to a filename and then import. No data will be imported but a file containing index definitions will be created. You must edit this file afterwards and supply the passwords for the schemas on all CONNECT statements.

Ø       Place the file to be imported on a separate physical disk from the oracle data files

Ø       Increase DB_CACHE_SIZE (DB_BLOCK_BUFFERS prior to 9i) considerably in the init$SID.ora file

Ø       Set the LOG_BUFFER to a big value and restart oracle.

Ø       Stop redo log archiving if it is running (ALTER DATABASE NOARCHIVELOG)

Ø       Create a BIG tablespace with a BIG rollback segment inside. Set all other rollback segments offline (except the SYSTEM rollback segment of course). The rollback segment must be as big as your biggest table (I think?)

Ø       Use COMMIT=N in the import parameter file if you can afford it

Ø       Use ANALYZE=N in the import parameter file to avoid time consuming ANALYZE statements

Ø       Remember to run the indexfile previously created

 Thanks – Shivmohan Purohit 






Oracle – Technical FAQ – Part 3

Q11) How do you implement the If statement in the select statement?
A11) We can implement the if statement in the select statement by using the decode statement.
e.g. select DECODE(EMP_CAT,’1′,’First’,’2′,’Second’,Null);
Here the Null is the else statement where null is done.
Q12) How many types of exceptions are there?

A12) a) System exceptions

e.g. When no_data_found, when too_many_rows

b) User Defined Exception

e.g. When my_exception then


Q13) What are the inline and the precompiler directives ?

A13) The inline and precompiler directives detect the values directly.


Q14) How do you use the same lov for 2 columns ?

A14) We can use the same lov for 2 columns by passing the return values in global values and using the global values in the code.


Q15) How many minimum groups are required for a matrix report ?

A15) The minimum number of groups in matrix report are 4.


Q16) What is the difference between the static and dynamic lov?

A16) The static lov contains the predetermined values while the dynamic lov contains values that come at run time.


Q17) What are snap shots and views ?

A17) Snapshots are mirror or replicas of tables. Views are build using the columns from one or more tables. The single table view can be updated but the view with multi table can not be updated.







RDBMS Based Interview Questions

Oracle RDBMS/ SQL Based Interview Questions 

What is denormalization and when would you go for it?

As the name indicates, denormalization is the reverse process of normalization. It’s the controlled introduction of redundancy in to the database design. It helps improve the query performance as the number of joins could be reduced.

How do you implement one-to-one, one-to-many and many-to-many relationships while designing tables?

One-to-One relationship can be implemented as a single table and rarely as two tables with primary and foreign key relationships.
One-to-Many relationships
are implemented by splitting the data into two tables with primary key and foreign key relationships.
Many-to-Many relationships
are implemented using a junction table with the keys from both the tables forming the composite primary key of the junction table.

What’s the difference between a primary key and a unique key?

Both primary key and unique key enforce uniqueness of the column on which they are defined. But by default primary key creates a clustered index on the column, where are unique creates a nonclustered index by default. Another major difference is that, primary key doesn’t allow NULLs, but unique key allows one NULL only.

Define candidate key, alternate key and composite key.

A candidate key is one that can identify each row of a table uniquely. Generally a candidate key becomes the primary key of the table. If the table has more than one candidate key, one of them will become the primary key, and the rest are called alternate keys. A key formed by combining at least two or more columns is called composite key.

What is a transaction and what are ACID properties?

A transaction is a logical unit of work in which, all the steps must be performed or none. ACID stands for Atomicity, Consistency, Isolation, Durability. These are the properties of a transaction.

What’s the difference between DELETE TABLE and TRUNCATE TABLE commands?

DELETE TABLE is a logged operation, so the deletion of each row gets logged in the transaction log, which makes it slow. TRUNCATE TABLE also deletes all the rows in a table, but it won’t log the deletion of each row, instead it logs the de-allocation of the data pages of the table, which makes it faster. Of course, TRUNCATE TABLE can be rolled back.


What are constraints? Explain different types of constraints.

Constraints enable the RDBMS enforce the integrity of the database automatically, without needing you to create triggers, rule or defaults. Types of constraints: NOT NULL, CHECK, UNIQUE, PRIMARY KEY, FOREIGN KEY


What is an index? What are the types of indexes? How many clustered indexes can be created on a table? I create a separate index on each column of a table. What are the advantages and disadvantages of this

Indexes are of two types. Clustered indexes and non-clustered indexes. When you craete a clustered index on a table, all the rows in the table are stored in the order of the clustered index key. So, there can be only one clustered index per table. Non-clustered indexes have their own storage separate from the table data storage. Non-clustered indexes are stored as B-tree structures (so do clustered indexes), with the leaf level nodes having the index key and it’s row locater. The row located could be the RID or the Clustered index key, depending up on the absence or presence of clustered index on the table.

If you create an index on each column of a table, it improves the query performance, as the query optimizer can choose from all the existing indexes to come up with an efficient execution plan. At the same t ime, data modification operations (such as INSERT, UPDATE, DELETE) will become slow, as every time data changes in the table, all the indexes need to be updated. Another disadvantage is that, indexes need disk space, the more indexes you have, more disk space is used.


What is RAID and what are different types of RAID configurations?

RAID stands for Redundant Array of Inexpensive Disks, used to provide fault tolerance to database servers. There are six RAID levels 0 through 5 offering different levels of performance, fault tolerance.
Write down the general syntax for a SELECT statements covering all the options.

Here’s the basic syntax:

SELECT select_list
FROM table_source
[WHERE search_condition]
[GROUP BY group_by__expression]
[HAVING search_condition]
[ORDER BY order__expression [ASC | DESC] ]


What is a join and explain different types of joins.

Joins are used in queries to explain how different tables are related. Joins also let you select data from a table depending upon data from another table.



What are triggers? How many triggers you can have on a table? How to invoke a trigger on demand?

Triggers are special kind of stored procedures that get executed automatically when an INSERT, UPDATE or DELETE operation takes place on a table. Triggers are generally used to implement business rules, auditing. Triggers can also be used to extend the referential integrity checks, but wherever possible, use constraints for this purpose, instead of triggers, as constraints are much faster.