Oracle 10g Most Frequently Asked Latest Interview Questions

What Is Oracle 10g?

Oracle 10g is a version of the Oracle Database. The g stands for "grid" to indicate that 10g is "grid-computing ready".

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 Index Cluster?

A cluster with an index on the cluster key.

What Is Cluster Key?
The related columns of the tables in a cluster are called the cluster key.

How Are The Index Updates?

Indexes are automatically maintained and used by Oracle. Changes to table data are automatically incorporated into all relevant indexes.

What Is An Oracle Index?

An index is an optional structure associated with a table to have direct access to rows, which can be created to increase the performance of data retrieval. Index can be created on one or more columns of a table.
Oracle 10g Most Frequently Asked Latest Interview Questions Answers
Oracle 10g Most Frequently Asked Latest Interview Questions Answers

When A Query Is Sent To The Database And An Index Is Not Being Used, What Type Of Execution Is Taking Place?

A table scan.

What Is The Difference Of A Left Join And An Inner Join Statement?

A LEFT JOIN will take ALL values from the first declared table and matching values from the second declared table based on the column the join has been declared on. An INNER JOIN will take only matching values from both tables

What Is An Advantage To Using A Stored Procedure As Opposed To Passing An Sql Query From An Application.

A stored procedure is pre-loaded in memory for faster execution. It allows the DBMS control of permissions for security purposes. It also eliminates the need to recompile components when minor changes occur to the database.

What Is A Cartesian Product? What Causes It?

A Cartesian product is the result of an unrestricted join of two or more tables. The result set of a three table Cartesian product will have x * y * z number of rows where x, y, z correspond to the number of rows in each table involved in the join. It is causes by specifying a table in the FROM clause without joining it to another table.

Why Is A Union All Faster Than A Union?

The union operation, you will recall, brings two sets of data together. It will *NOT* however produce duplicate or redundant rows. To perform this feat of magic, a SORT operation is done on both tables. This is obviously computationally intensive, and uses significant memory as well. A UNION ALL conversely just dumps collection of both sets together in random order, not worrying about duplicates.

What Are Some Advantages To Using Oracle's Create Database Statement To Create A New Database Manually?

You can script the process to include it in a set of install scripts you deliver with a product.

You can put your create database script in CVS for version control, so as you make changes or adjustments to it, you can track them like you do changes to software code.

You can log the output and review it for errors. You learn more about the process of database creation, such as what options are available and why.

What Are The Pros And Cons Of Using Triggers?

A trigger is one or more statements of SQL that are being executed in event of data modification in a table to which the trigger belongs.

Triggers enhance the security, efficiency, and standardization of databases.

Triggers can be beneficial when used:

to check or modify values before they are actually updated or inserted in the database. This is useful if you need to transform data from the way the user sees it to some internal database format.
to run other non-database operations coded in user-defined functions
to update data in other tables. This is useful for maintaining relationships between data or in keeping audit trail information.
to check against other data in the table or in other tables. This is useful to ensure data integrity when referential integrity constraints aren’t appropriate, or when table check constraints limit checking to the current table only.

What Is The Maximum Number Of Triggers, Can Apply To A Single Table?

12 triggers.

What Is The Output Of Sign Function?

1 for positive value,
0 for Zero,
-1 for Negative value.

What Are The More Common Pseudo-columns?

SYSDATE, USER , UID, CURVAL, NEXTVAL, ROWID, ROWNUM

What Are Pl/sql Cursor Exceptions?
Cursor_Already_Open, Invalid_Cursor

Any Three Pl/sql Exceptions?
Too_many_rows,
No_Data_Found,
Value_Error,
Zero_Error,
Others

To See Current User Name

Sql> show user;

If A View On A Single Base Table Is Manipulated Will The Changes Be Reflected On The Base Table?

If changes are made to the tables and these tables are the base tables of a view, then the changes will be reference on the view.

Can A View Be Updated/inserted/deleted? If Yes - Under What Conditions?

A View can be updated/deleted/inserted if it has only one base table if the view is based on columns from one or more tables then insert, update and delete is not possible.

What Are The Advantages Of View?

- To protect some of the columns of a table from other users.
- To hide complexity of a query.
- To hide complexity of calculations.

What Is Cycle/no Cycle In A Sequence?

CYCLE specifies that the sequence continue to generate values after reaching either maximum or minimum value. After pan-ascending sequence reaches its maximum value, it generates its minimum value. After a descending sequence reaches its minimum, it generates its maximum.

NO CYCLE specifies that the sequence cannot generate more values after reaching its maximum or minimum value.

Which Date Function Returns Number Value?

months_between

Display Odd/ Even Number Of Records

Odd number of records:
select * from emp where (rowid,1) in (select rowid, mod(rownum,2) from emp);
1
3
5

Even number of records:
select * from emp where (rowid,0) in (select rowid, mod(rownum,2) from emp)
2
4
6

To View Installed Oracle Version Information

SQL> select banner from v$version;

Find Out Nth Highest Salary From Emp Table

SELECT DISTINCT (a.sal) FROM EMP A WHERE &N = (SELECT COUNT (DISTINCT (b.sal)) FROM EMP B WHERE a.sal<=b.sal);

Enter value for n: 2
SAL
---------------
3700

Explicit Cursor Attributes

There are four cursor attributes used in Oracle

cursor_name%Found,
cursor_name%NOTFOUND,
cursor_name%ROWCOUNT,
cursor_name%ISOPEN

How Do I Display Row Number With Records?

To achive this use rownum pseudocolumn with query, like
SQL> select rownum, ename from emp;

Output:
-----------------
1 Scott
2 Millor
3 Jiyo
4 Smith

Switch To Dos Prompt

SQL> host

How To Access The Current Value And Next Value From A Sequence? Is It Possible To Access The Current Value In A Session Before Accessing Next Value?

Sequence name CURRVAL, sequence name NEXTVAL. It is not possible. Only if you access next value in the session, current value can be accessed.

What Is A Database Link?

Database link is a named path through which a remote database can be accessed.

If Unique Key Constraint On Date Column Is Created, Will It Validate The Rows That Are Inserted With Sysdate?

It won’t, Because SYSDATE format contains time attached with it.

How Will You Activate/deactivate Integrity Constraints?

The integrity constraints can be enabled or disabled by ALTER TABLE ENABLE CONSTRAINT / DISABLE CONSTRAINT.

Where The Integrity Constraints Are Stored In Data Dictionary?

The integrity constraints are stored in USER_CONSTRAINTS.

What Are The Pre-requisites To Modify Datatype Of A Column And To Add A Column With Not Null Constraint?

- To modify the datatype of a column the column must be empty.
- To add a column with NOT NULL constrain, the table must be empty.

How Many Long Columns Are Allowed In A Table? Is It Possible To Use Long Columns In Where Clause Or Order By?

Only one LONG column is allowed. It is not possible to use LONG column in WHERE or ORDER BY clause.

What Is Difference Between Char And Varchar2? What Is The Maximum Size Allowed For Each Type?

CHAR pads blank spaces to the maximum length.
VARCHAR2 does not pad blank spaces.
For CHAR the maximum length is 255 and 2000 for VARCHAR2.

What Are The Data Types Allowed In A Table?

CHAR, VARCHAR2, NUMBER, DATE, RAW, LONG and LONG RAW.

What Is On Delete Cascade?

When ON DELETE CASCADE is specified Oracle maintains referential integrity by automatically removing dependent foreign key values if a referenced primary or unique key value is removed.

What Is The Usage Of Savepoints?

SAVEPOINTS are used to subdivide a transaction into smaller parts. It enables rolling back part of a transaction. Maximum of five save points are allowed.

What Is Referential Integrity Constraint?

Maintaining data integrity through a set of rules that restrict the values of one or more columns of the tables based on the values of primary key or unique key of the referenced table.

What Is An Integrity Constraint?

Integrity constraint is a rule that restricts values to a column in a table.

What Is Rowid?

ROWID is a pseudo column attached to each row of a table. It is 18 characters long, blockno, rownumber are the components of ROWID.

Explain Union, Minus, Union All And Intersect?

INTERSECT - returns all distinct rows selected by both queries.
MINUS - returns all distinct rows selected by the first query but not by the second.
UNION - returns all distinct rows selected by either query
UNION ALL - returns all rows selected by either query, including all duplicates.

Difference Between Substr And Instr?

INSTR (String1, String2 (n, (m)),
INSTR returns the position of the m-th occurrence of the string 2 in string1. The search begins from nth position of string1.

SUBSTR (String1 n, m)
SUBSTR returns a character string of size m in string1, starting from n-th position of string1.

Explain Connect By Prior?

Retrieves rows in hierarchical order

eg: select empno, ename from emp where.

What Is Correlated Sub-query?

Correlated sub-query is a sub-query, which has reference to the main query.

What Is The Sub-query?

Sub-query is a query whose return values are used in filtering conditions of the main query.

What Is A Join? Explain The Different Types Of Joins?

Join is a query, which retrieves related columns or rows from multiple tables.

Self Join – Joining the table with itself.

Equi Join – Joining two tables by equating two common columns.

Non-Equi Join – Joining two tables by equating two common columns.

Outer Join – Joining two tables in such a way that query can also retrieve rows that do not have corresponding join value in the other table.

What Is Difference Between Truncate & Delete?

TRUNCATE commits after deleting entire table i.e., cannot be rolled back.
Database triggers do not fire on TRUNCATE
DELETE allows the filtered deletion. Deleted records can be rolled back or committed.
Database triggers fire on DELETE.

What Is A Transaction?

Transaction is logical unit between two commits and commit and rollback.

What Are The Types Of Sql Statement?

Data Definition Language: CREATE, ALTER, DROP, TRUNCATE, REVOKE, NO AUDIT & COMMIT.
Data Manipulation Language: INSERT, UPDATE, DELETE, LOCK TABLE, EXPLAIN PLAN & SELECT.

Transactional Control: COMMIT & ROLLBACK.

Session Control: ALTERSESSION & SET ROLE.

System Control: ALTER SYSTEM.

What Is An Oracle Sequence?

A sequence generates a serial list of unique numbers for numerical columns of a database’s tables.

What Is System Tablespace And When Is It Created?

Every Oracle database contains a tablespace named SYSTEM, which is automatically created when the database is created. The SYSTEM tablespace always contains the data dictionary tables for the entire database.

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 Are The Components Of Logical Database Structure Of Oracle Database?

There are tablespaces and database’s schema objects.

What Are The Components Of Physical Database Structure Of Oracle Database?

Oracle database is comprised of three types of files. One or more datafiles, two are more redo log files, and one or more control files.

What Are The Dictionary Tables Used To Monitor A Database Space?

DBA_FREE_SPACE
DBA_SEGMENTS
DBA_DATA_FILES.
SQL*Plus Statements

How Will You Enforce Security Using Stored Procedures?

Don’t grant user access directly to tables within the application.
Instead grant the ability to access the procedures that access the tables.
When procedure executed it will execute the privilege of procedures owner. Users cannot access tables except via the procedure.

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.

List The Factors That Can Affect The Accuracy Of The Estimations?

- The space used transaction entries and deleted records, does not become free immediately after completion due to delayed cleanout.
- Trailing nulls and length bytes are not stored.
- Inserts of, updates to and deletes of rows as well as columns larger than a single data block, can cause fragmentation a chained row pieces.

What Are Disadvantages Of Having Raw Devices?

We should depend on export/import utility for backup/recovery (fully reliable)
The tar command cannot be used for physical file backup, instead we can use dd command, which is less flexible and has limited recoveries.

When Will Be A Segment Released?

When Segment is dropped.
When Shrink (RBS only)
When truncated (TRUNCATE used with drop storage option)

What Is Hit Ratio?

It is a measure of well the data cache buffer is handling requests for data.
Hit Ratio = (Logical Reads – Physical Reads – Hits Misses)/ Logical Reads.

What Is A Rollback Segment Entry?

It is the set of before image data blocks that contain rows that are modified by a transaction.
Each rollback segment entry must be completed within one rollback segment.
A single rollback segment can have multiple rollback segment entries.

What Is Use Of Rollback Segments In Oracle Database?
They allow the database to maintain read consistency between multiple transactions.

What Is Advantage Of Having Disk Shadowing / Mirroring?

Shadow set of disks save as a backup in the event of disk failure. In most operating systems if any disk failure occurs it automatically switchover to place of failed 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.

What Is Redo Log File Mirroring? How Can Be Achieved?

Process of having a copy of redo log files is called mirroring.
This can be achieved by creating group of log files together, so that LGWR will automatically writes them to all the members of the current on-line redo log group. If any one group fails then database automatically switch over to next group. It degrades performance.

How To Implement The Multiple Control Files For An Existing Database?

Shutdown the database
Copy one of the existing controlfile to new location
Edit Config ora file by adding new control filename
Restart the database.

What Is Redo Log Buffer?

Changes made to the records are written to the on-line redo log files. So that they can be used in roll forward operations during database recoveries. Before writing them into the redo log files, they will first brought to redo log buffers in SGA and LGWR will write into files frequently. LOG_BUFFER parameter will decide the size.

What Is Meant By Recursive Hints?

Number of times processes repeatedly query the dictionary table is called recursive hints. It is due to the data dictionary cache is too small. By increasing the SHARED_POOL_SIZE parameter we can optimize the size of data dictionary cache.

What Is Dictionary Cache?

Dictionary cache is information about the database objects stored in a data dictionary table.

What Is Database Buffers?

Database buffers are cache in the SGA used to hold the data blocks that are read from the data segments in the database such as tables, indexes and clusters DB_BLOCK_BUFFERS parameter in INIT.ORA decides the size.

What Are The Factors Causing The Reparsing Of Sql Statements In Sga?

Due to insufficient shared pool size.
Monitor the ratio of the reloads takes place while executing SQL statements. If the ratio is greater than 1 then increase the SHARED_POOL_SIZE.
Database Logical & Physical Architecture

What Is A Data Segment?

Data segment are the physical areas within a database block in which the data associated with tables and clusters are stored.

What Is Mean By Program Global Area (pga)?

It is area in memory that is used by a single Oracle user process.

What Is A Shared Pool?

Shared pool in oracle contains cache information that collects, parses, interprets and executes SQL statements that goes against database. This shared pool acts like a buffer for these SQL statements.

What Is Sga?

The System Global Area in an Oracle database is the area in memory to facilitate the transfer of information between users. It holds the most recently requested structural information between users. It holds the most recently requested structural information about the database. The structure is database buffers, dictionary cache, redo log buffer and shared pool area.

What Is A Cluster Key?

The related columns of the tables are called the cluster key. The cluster key is indexed using a cluster index and its value is stored only once for multiple tables in the cluster.

What Are Clusters?

Group of tables physically stored together because they share common columns and are often used together is called cluster.

What Is A Control File?

Database’s overall physical architecture is maintained in a file called control file. It will be used to maintain internal consistency and guide recovery operations. Multiple copies of control files are advisable.

It Is Possible To Use Raw Devices As Data Files And What Are The Advantages Over File System Files?

The advantages over file system files are that I/O will be improved because Oracle is bye-passing the kernel which writing into disk. Disk corruption will be very less.

How Can We Plan Storage For Very Large Tables?

Limit the number of extents in the table
Separate table from its indexes.
Allocate sufficient temporary storage.

How Will You Monitor The Space Allocation?

By querying DBA_SEGMENT table/view

What Are The Advantages Of Views?

Provide an additional level of table security, by restricting access to a predetermined set of rows and columns of a table.
 Hide data complexity.
 Simplify commands for the user.
 Present the data in a different perspective from that of the base table.
 Store complex queries.

Can A View Based On Another View?

Yes.

Do A View Contain Data?

Views do not contain or store data.

What Is An Oracle View?

A view is a virtual table. Every view has a query attached to it. (The query is a SELECT statement that identifies the columns and rows of the table(s) the view uses.)

What Is Oracle Table?

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

Can A Tablespace Hold Objects From Different Schemes?

Yes.

Can Objects Of The Same Schema Reside In Different Tablespaces?

Yes.

What Are Schema Objects?

Schema objects are the logical structures that directly refer to the database’s data. Schema objects include tables, views, sequences, synonyms, indexes, clusters, database triggers, procedures, functions packages and database links.

What Is Schema?

A schema is collection of database objects of a user.

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.

Why Query Fails Sometimes?

Rollback segment dynamically extent to handle larger transactions entry loads.
A single transaction may wipeout all available free space in the rollback segment tablespace. This prevents other user using rollback segments.

How The Space Utilization Takes Place Within Rollback Segments?

It will try to fit the transaction in a cyclic fashion to all existing extents. Once it found an extent is in use then it forced to acquire a new extent (number of extents is based on the optimal size)

How Will You Create Multiple Rollback Segments In A Database?

- Create a database, which implicitly creates a SYSTEM rollback segment in a SYSTEM tablespace.
- Create a second rollback segment name R0 in the SYSTEM tablespace.
- Make new rollback segment available (after shutdown, modify init.ora file and start database)
- Create other tablespaces (RBS) for rollback segments.
- Deactivate rollback segment R0 and activate the newly created rollback segments.

What Is The Functionality Of System Table Space?

To manage the database level transactions such as modifications of the data dictionary table that record information about the free space usage.

What Is The Optimal Parameter?

It is used to set the optimal length of a rollback segment.

What Is The Role Of Pctfree Parameter Is Storage Clause?

This is used to reserve certain amount of space in a block for expansion of rows.

How Does Space Allocation Table Place Within A Block?

Each block contains entries as follows
Fixed block header
Variable block header
Row Header, row date (multiple rows may exists)
PCTEREE (% of free space for row updating in future)

What Is The Significance Of Having Storage Clause?

We can plan the storage for a table as how much initial extents are required, how much can be extended next, how much % should leave free for managing row updating, etc.,

Which Parameter In Storage Clause Will Reduce Number Of Rows Per Block?

PCTFREE parameter
Row size also reduces no of rows per block.

What Is Meant By Free Extent?

A free extent is a collection of continuous free blocks in tablespace. When a segment is dropped its extents are reallocated and are marked as free.

How Will You Force Database To Use Particular Rollback Segment?

SET TRANSACTION USE ROLLBACK SEGMENT rbs_name.

List The Optional Flexible Architecture (ofa) Of Oracle Database? How Can We Organize The Tablespaces In Oracle Database To Have Maximum Performance?

SYSTEM – Data dictionary tables.
DATA - Standard operational tables.
DATA2- Static tables used for standard operations
INDEXES – Indexes for Standard operational tables.
INDEXES1 – Indexes of static tables used for standard operations.
TOOLS – Tools table.
TOOLS1 – Indexes for tools table.
RBS – Standard Operations Rollback Segments,
RBS1,RBS2 – Additional/Special Rollback segments.
TEMP – Temporary purpose tablespace
TEMP_USER – Temporary tablespace for users.
USERS – User tablespace.

How Will You Swap Objects Into A Different Table Space For An Existing Database?

- Export the user
- Perform import using the command imp system/manager file=export.dmp indexfile=newrite.sql. This will create all definitions into newfile.sql.
- Drop necessary objects.
- Run the script newfile.sql after altering the tablespaces.
- Import from the backup for the necessary objects.

What Is An Index? How It Is Implemented In Oracle Database?

An index is a database structure used by the server to have direct access of a row in a table. An index is automatically created when a unique of primary key constraint clause is specified in create table command

What Is A Schema?

The set of objects owned by user account is called the schema.

What Is Parallel Server?

Multiple instances accessing the same database (only in multi-CPU environments)

What Is A Database Instance? Explain.

A database instance (Server) is a set of memory structure and background processes that access a set of database files. The processes can be shared by all of the users.

The memory structure that is used to store the most queried data from database. This helps up to improve database performance by decreasing the amount of I/O performed against data file.

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.

What Does A Control File Contains?

- Database name
- Names and locations of a database’s files and redolog files.
- Time stamp of database creation.

What Is Row Chaining?

In circumstances, all of the data for a row in a table may not be able to fit in the same data block. When this occurs, the data for the row is stored in a chain of data block (one or more) reserved for that segment.

How To Define Data Block Size?

A data block size is specified for each Oracle database when the database is created. A database users and allocated free database space in Oracle data blocks. Block size is specified in init.ora file and cannot be changed latter.

What Is Data Block?

Oracle database’s data is stored in data blocks. One data block corresponds to a specific number of bytes of physical database space on disk.

What Is Network Database Link?

Network database link is created and managed by a network domain service. A network database link can be used when any user of any database in the network specifies a global object name in a SQL statement or object definition.

What Is Public Database Link?

Public database link is created for the special user group PUBLIC. A public database link can be used when any user in the associated database specifies a global object name in a SQL statement or object definition.

What Is Private Database Link?

Private database link is created on behalf of a specific user. A private database link can be used only when the owner of the link specifies a global object name in a SQL statement or in the definition of the owner’s views or procedures.

What Are The Types Of Database Links?

Private database link, public database link & network database link.

What Is Database Link?

A database link is a named object that describes a “path” from one database to another.

When Can Hash Cluster Used?

Hash clusters are better choice when a table is often queried with equality queries. For such queries the specified cluster key value is hashed. The resulting hash key value points directly to the area on disk that stores the specified rows.

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 The Use Of Redo Log Information?

The information in a redo log file is used only to recover the database from a system or media failure prevents database data from being written to a database’s data files.

What Is The Function Of Redo Log?

The primary function of the redo log is to record all changes made to data.

What Is A Redo Log?

The set of redo log files for a database is collectively known as the database redo log.

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.

What Is A Datafile?

Every Oracle database has one or more physical data files. A database’s data files contain all the database data. The data of logical database structures such as tables and indexes is physically stored in the data files allocated for a database.

What Is A Temporary Segment?

When the statement finishes execution, the temporary segment extents are released to the system for future use.

What Are The Uses Of Rollback Segment?

To generate read-consistent database information during database recovery and to rollback uncommitted transactions by the users.

What Is Rollback Segment?

A database contains one or more rollback segments to temporarily store “undo” information.

What Is An Index Segment?

Each index has an index segment that stores all of its data.

What Are The Different Types Of Segments?

Data segment, index segment, rollback segment and temporary segment.

What Is A Segment?

A segment is a set of extents allocated for a certain logical structure.

Post a Comment

Previous Post Next Post