Oracle Questions

Q:

What is a Trigger? Explain Types of PL/SQL Triggers.

Answer

A database trigger is procedural code that is automatically executed in response to certain events on a particular table or view in a database. The trigger is mostly used for maintaining the integrity of the information on the database.


Syntax:


CREATE OR REPLACE TRIGGER [Trigger Name] [Before / After / Instead Of]


ON [schema].[table]


<PL/SQL subprogram>


 


Types of PL/SQL triggers : 


> Row trigger          - The trigger fires for each ROW affected.


> Statement trigger - The trigger is fired once when the condition is matched


> Before and After trigger - The BEFORE trigger run the trigger action before the insert, update or delete statement. The AFTER trigger runs the trigger action after the insert, update or delete statement is executes.

Report Error

View answer Workspace Report Error Discuss

Subject: Oracle

1 2191
Q:

What are the types of constraints avaialable in oracle?

Answer

Oracle constraints are used to maintain consistent of data and ensure the data is properly maintained. A constraint is more or less a restriction we try to apply on a table.
Types of constraints:
- Check constraints
- NOT NULL constraint
- PRIMARY KEY constraint
- REFERENCES constraint
- UNIQUE constraint

Report Error

View answer Workspace Report Error Discuss

Subject: Oracle

0 2182
Q:

Define PL/SQL sequences and write syntax for a sequence

Answer

A sequence is a database object that is used to generate sequential number.


CREATE SEQUENCE seqname [increment] [minimum value][maximum value][start][cache][cycle]               Nextval and currval lets us get the next value and current value from the sequence.

Report Error

View answer Workspace Report Error Discuss

Subject: Oracle

0 2154
Q:

What is correlated query? Explain its uses.

Answer

In a correlated query, the outer query is related to the inner query. This means one or more columns in the outer query are referenced. It’s used when the outer queries value is being used by inner query. For example, we need to find which employee had more perks in the current month than they did in the previous month. The correlated subquery is executed for each row of perks information in the parent query to first determine what the perks were for each employee in the previous month. This data, in turn, is compared to perks for each employee in the current month, and only those employees whose perks in the current month were greater that their previous month's perks are returned.

Report Error

View answer Workspace Report Error Discuss

Subject: Oracle

0 2140
Q:

How to recover a dropped table?

Answer

Dropped tables can be recovered using DROP TABLE flashback. It works the way recycle bin works.
Example:
FLASHBACK TABLE EMPLOYEE TO BEFORE DROP;
The most recently dropped table with that original name is retrieved from the recycle bin, with its original name.

Report Error

View answer Workspace Report Error Discuss

Subject: Oracle

0 2115
Q:

A data warehouse is composed of

A) current data B) internal and external data sources
C) historical data from legacy systems D) historical & current data
 
Answer & Explanation Answer: C) historical data from legacy systems

Explanation:

A data warehouse is a relational database that is designed for query and analysis rather than transaction processing. It usually contains historical data that is derived from transaction data, but it can include data from other sources. Data warehouses are designed to help you analyze your data.

Report Error

View Answer Report Error Discuss

Filed Under: Oracle
Job Role: Database Administration , IT Trainer

1 2109
Q:

What is an Index? Explain how to create an Index.

Answer

An index is a object which is used to improve performance during retrieval of records.


CREATE [UNIQUE] INDEX index_name 


ON employee[emp_id, emp_name,dept_id]


[COMPUTE STATISTICS]


The UNIQUE keyword is used when combined values of the index should be unique.


The COMPUTE STATISTICS during the creation of index optimizes the plan of execution of the SQL statement and improves performance.

Report Error

View answer Workspace Report Error Discuss

Subject: Oracle

0 2108
Q:

Explain how PL/SQL exceptions are raised.

Answer

PL/SQL exceptions are raised using the RAISE command. This command is used when exceptions are defined by programmer and not implicit exceptions.


 


Example:


Declare and raising an exception:


DECLARE


short_of_attendance EXCEPTION;


min_attendance NUMBER(4);


BEGIN


...


IF min_attendance < 10 THEN


RAISE short_of_attendance;


END IF;


EXCEPTION


WHEN short_of_attendance THEN


-- handle the error


END;

Report Error

View answer Workspace Report Error Discuss

Subject: Oracle

0 2100