Set - 4

Question 1 :

What is correlated sub-query?

Answer :

Correlated sub-query is a sub-query, which has reference to the main query.
Retrieves rows in hierarchical order eg.
select empno, ename from emp where.

Question 2 :

Difference between SUBSTR and INSTR?

Answer :

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.

Question 3 :


Answer :

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.

Question 4 :

What is ROWID?

Answer :

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

Question 5 :

What is the fastest way of accessing a row in a table?

Answer :

Using ROWID.

Question 6 :

What is an integrity constraint?

Answer :

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

Question 7 :

What is referential integrity constraint?

Answer :

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.

Question 8 :

What is the usage of SAVEPOINTS?

Answer :

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.

Question 9 :


Answer :

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.

Question 10 :

What are the data types allowed in a table?

Answer :


Question 11 :

What is difference between CHAR and VARCHAR2? What is the maximum SIZE allowed for each type?

Answer :

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.

Question 12 :

How many LONG columns are allowed in a table? Is it possible to use LONG columns in WHERE clause or ORDER BY?

Answer :

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

Question 13 :

What are the pre-requisites to modify datatype of a column and to add a column with NOT NULL constraint?

Answer :

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

Question 14 :

Where the integrity constraints are stored in data dictionary?

Answer :

The integrity constraints are stored in USER_CONSTRAINTS.

Question 15 :

How will you activate/deactivate integrity constraints?

Answer :

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

Question 16 :

If unique key constraint on DATE column is created, will it validate the rows that are inserted with SYSDATE?

Answer :

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

Question 17 :

What is a database link?

Answer :

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

Question 18 :

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?

Answer :

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

Question 19 :

What is CYCLE/NO CYCLE in a Sequence?

Answer :

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.

Question 20 :

What are the advantages of VIEW?

Answer :

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

Question 21 :

Can a view be updated/inserted/deleted? If Yes - under what conditions?

Answer :

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.

Question 22 :

If a view on a single base table is manipulated will the changes be reflected on the base table?

Answer :

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.

Question 23 :

Which of the following statements is true about implicit cursors?

Answer :

1. Implicit cursors are used for SQL statements that are not named.
2. Developers should use implicit cursors with great care.
3. Implicit cursors are used in cursor for loops to handle data processing.
4. Implicit cursors are no longer a feature in Oracle.

Question 24 :

Which of the following is not a feature of a cursor FOR loop?

Answer :

1. Record type declaration.
2. Opening and parsing of SQL statements.
3. Fetches records from cursor.
4. Requires exit condition to be defined.

Question 25 :

A developer would like to use referential datatype declaration on a variable. The variable name is EMPLOYEE_LASTNAME, and the corresponding table and column is EMPLOYEE, and LNAME, respectively. How would the developer define this variable using referential datatypes?

Answer :

1. Use employee.lname%type.
2. Use employee.lname%rowtype.
3. Look up datatype for EMPLOYEE column on LASTNAME table and use that.
4. Declare it to be type LONG.

Question 26 :

Which three of the following are implicit cursor attributes?

Answer :

1. %found
2. %too_many_rows
3. %notfound
4. %rowcount
5. %rowtype