Vous êtes sur la page 1sur 75

May

18

Oracle PL/SQL Interview Question and


Answers
INTERVIEW QUESTIONS(SQL AND PL/SQL) AND ANSWERS
1. Select emp name, emp no, sal from emp who is getting the salary greater than the supervisor
salary.
Select empno, ename, sal from emp where sal>all(select sal from emp where
job='MANAGER');
2. Can you change null value into not null value? Can you change not null value into null value?
No, We can not change (modify column) null value into not null. But we can change not
null value into null value.
3. Delete the duplicate row from the emp table?
Delete from emp a where rowid not in(select min(rowid) from emp where
deptno=a.deptno); (OR)
Delete from emp where rowid not in(select min(rowid) from emp group by deptno);
4. Select entire employees names and their supervisor name?
Select a.empno, a.ename, b.ename from emp a, emp b where a.mgr=b.empno;
5. Select job from emp table whose total salary are more than 50,000?
Select job from emp where sal>50000;
Ans: No rows selected
6. What the SIGN function will return?
It will return sign of value without its magnitude.
7. What is the wrong in the following program?
For i in 1...5 loop
update emp set comm=500 where sal=1000;
end loop;
Ans: SP2-0734: unknown command beginning "For i in 1..." - rest of line ignored.
8. Suppose 10 users are using one procedure how many copy of the procedure will be there at
that time.

Ans: 10
9. Write a query to display a procedure or function.
Select text from user_source where name='SAMPLE';
Here 'SAMPLE' is a procedure.
10. What is use of pl/sql?
PL/SQL provides a procedural extension to SQL. It combines the data manipulation
power of SQL with the data processing
power of procedural language.
11. What is package?
Package is a container which contains related objects.
12. What is de-normalization?
The intentional introduction of redundancy in the table is called de-normalization.
13. What is join?
Extracting records one or more table with proper where or join condition. They are classified into
two types. They are inner join and outer join.
Equi-join,Non-equi-join,Self join ---> Inner join and Left outer join, Right Outer join--Outer Join..
14. What is self join?
Same table with different alias.
15. Write the query identifying duplicate records from the table?
Select * from emp a where rowid not in(select min(rowid) from emp where
deptno=a.deptno);
16. How do you copy one table structure without its data?
Create table emp_temp as select * from emp where 1=2; (i.e. logic is false. 1=2)
17. What is difference between procedure and function?
PROCEDURE
1. Procedure can not return a value using return statement.
2. Can not be called from SQL statements.
3. Can be called from Browser.
4. If we want perform a task write procedure.
18. What are types of exceptions?
1. Trappable 2. Non-Trappable.

FUNCTION
1. Must return a value.
2. Can be called from SQL command
3. Can not be called from Browser.
4. If we want compute a value write f

System error

Pre-defined error

User-defined error.

Non-pre-defined error.

19. What are types of error?


1. Pre-defined.
2. Non-pre-defined.
3. User-defined.
20. Pre-defined:- Only error handled by user. Error created, error raised by oracle. Predefined
means already defined.
Non-Predefined:- Error created and handled by user. Only error raised by oracle. Non
predefined means not already defined.
User defined:- Error created, raised and handled by user. Here three events are done by user.
That is everything done by user.
21. What are pre-defiened exceptions?
Exception is error handling part of pl/sql.
Exceptions are classified into three types.1. Pre-defined exceptions 2. Non-Predefined
exceptions. 3. User-defined exceptions.
Pre-defined exceptions:
1. Cursor_already_open
2. Dup_val_on_index
3. Invalid_cursor
4. Invalid_number
5. Login denied
6. Not_logged_on
7. Storage_error
8. Program_error
9. Value_error
10. Too_many_rows
11. Zero_divide
12. No_data_found
13. Timeout_on_resource
14. Transaction_backed_out

scade:

15. Access_into_null
16. Collection_is_null
17. Rowtype_mismatch
18. Subscript_beyond_count
19. Subscript_outside_limit
22. What is difference between implicit cursor and explicit cursor?
The events are syntax,semantic,parsing,existence,create a cursor,open,fetch and close by done by
system which is called implicit cursor.(These 8 actions are done implicitly through system itself)
The events create a cursor,open,fetch and close by a user which is called explicit cursor. Implicit
cursor performance is slow. But explicit cursor performance is fast. So we use explicit cursor.
23. Can you create synonyms for objects declared within package or subprograms?
No, We can not create synonyms for objects declared within package or subprograms.
24. What are the different types of constraints and explain each.
Constraints are conditions.
Domain integrity constraint-check constraint, not null constraint
Entity integrity constraint-primary key constraint, unique key constraint
Referential integrity constraint-Foreign key constraint, on delete cascade
Check constraint:
It check the boundaries of value.
Not null constraint:
It does not allow null value in a column of database table.
Unique constraint:
It does not allow the duplicate value in a column or set of
column of table.
Primary key constraint:
It does not allow the duplicate values and null values in a
column or set of columns of table.
Foreign key constraint:
It is a local representation of remote primary
key(Referential Integrity)
When on-delete-cascade is specified oracle maintains referential integrity by automatically
removing dependent foreign key values if a referenced primary key value or unique key value is
removed.
25. What is output of program?
Declare
I char(5)="HELLO";
J char(10)="HELLO' ");
Begin
If I=J Then
True;
Else
False;
End if;
End;
OUTPUT:
I char(5)="HELLO";

*
ERROR at line 2:
ORA-06550: line 2, column 13:
PLS-00103: Encountered the symbol "=" when expecting one of the following:
:= ; not null default character
The symbol ":= was inserted before "=" to continue.
ORA-06550: line 3, column 14:
PLS-00103: Encountered the symbol "=" when expecting one of the following:
:= ; not null default character
26. What is difference between Delete, Truncate and Drop?
DELETE
1.Delete one or more records
2. Where condition.
3.Can be rolled back.
4. It maintains log.
5. Create trigger

TRUNCATE
Drop all records leaving out of structure
also.
We can not give where condition.
It can not be rolled back.
No log
It will not create trigger.

27. What is data base link and its use?


1. Data base link is a path between two databases.
2. Database link is used to access remote database.
28. Which one attribute is used to check whether the cursor is opened or not?
Ans: %isopen
29. Lexical analysis is used in which part?
Ans: PL/SQL part.
30. How do you initialize date field in oracle database?
##DATE##, #DATE#, #DCDATE# Ans:#DATE#
31. What will be the output of the following program?
Create sequence Hi
start with 0
Increment by 1;
OUTPUT:
ERROR at line 1:
ORA-04006: START WITH cannot be less than MINVALUE
32. Which one is DML statement?
create,alter,select,drop Ans: Select

DROP
Erase the table.

All pending transactio


Erases from DDL

33. How many rows the following query will select?


A
B
40
50
0
null
null
null
30
20
Select col1, col2 from A,B?
(a)4
(b)0 (c)one (d)16 Ans:16 (Example:- select a.sal,b.comm from emp a,emp
b;)
34. Declare
Raise_paise exception;
Char I=10;
Char J=5;
Begin
Char I=10;
Char J=5;
If I=J then
Raise_Paise;
End if;
When raise_paise then
Message("some message");
End;
Which is wrong in the following program?
OUTPUT:
Char I=10;
*
ERROR at line 3:
ORA-06550: line 3, column 10:
PLS-00103: Encountered the symbol "=" when expecting one of the following:
:= . ( @ % ; not null range default character
35. What will be the output of the following program?
Declare
L1 Real;
L2 Integer;
L3 Float;
L4 Pls_integer;
L5 Double;
Begin
Null;
End;
OUTPUT:
L5 Double;
ERROR at line 6:
ORA-06550: line 6, column 13:

PLS-00103: Encountered the symbol ";" when expecting one of the following:
precision
The symbol "precision" was substituted for ";" to continue.
36. Where the error will be generated?
select empno,
ename,
sal,
avg(sal)
from emp where avg(sal)>900
group by empno,
ename order by avg(sal)
OUTPUT:
from emp where avg(sal)>900
*
ERROR at line 5:
ORA-00934: group function is not allowed here
37. Select Distinct (qty) from the following table?
Emp_name
Qty
x
500
y
500
x
0
j
200
m
400

(a)4 (b)5 (c)one (d)null


Ans:4

38. Which one is not correct in the following?


(a)Sequence can not be used in view
(b)Sequnece can not be used in the SELECT statement which is having GROUP By
clause.
(c)Sequence can not be used SUBQUERY where the subquery contain GROUP BY
clause.
Ans: (b)
39. How do you select next value from a sequence table?
(a) Select sequence_name.nextval
(b) Select sequence_name.nextvalue
Ans :(a) Select sequence_name.nextval
40. If you want to create foreign key which one is necessary?
(a)The main table contain primary key
(b)The main table contain unique key
(c)The main table contains primary key and unique key
(d)None of these.
Ans:(a)The main table contain primary key

41. How many types of sql statements are there and what they are?
1. Data Definition Language statements
2. Data Manipulation Language statements
3. Transaction Control statements
4. Data Control Language statements
5. Session Control statements
6. System Control Statements.
1. Data Definition Language statements
Create,alter,drop,truncate,no audit and comment.
2. Data Manipulation Language statements
insert,update,delete,select,lock table and explain plan.
3. Transaction Control language statements
commit,rollback and savepoint.
4. Data control language statements.
Grant and Revoke.
5. Session control statements
Alter session and set role
6. System Control statements
Alter system
42. What is trigger?
Trigger is a plsql block that gets executed automatically as well as event occurs. That is
implicitly called.
Totally 12 triggers and 3 view triggers.
1. Before insert row
11. After update statement
2. Before update row
12. After delete statement
3. Before delete row
4. After insert row
5. After update row
6. After delete row
7. Before insert statement
8. Before update statement
9. Before delete statement
10. After insert statement
43. What is the use of stored procedure?
1. Modularity
2. Reusability
3. Maintainability
4. Extensibility
5. One time compilation
44. What are oracle key words?
Insert, Update, Delete, Select, Create, Alter, Drop.

45. What is the difference between null and =null.


Null is valid. =Null is not valid.
46. What is the use of reference variable?
Reference variable is used to process data to server.
47. How many triggers can be written in a single table?
Ans: 12 triggers.
48. What is meant by lexical analysis?
PL/SQL text can contain group of characters is known as Lexical analysis. It has four units. They
are identifiers, literals, comments and delimiters.
49. What is the difference between primary key and unique key?
Primary key constraint: It does not allow null value.
Unique key constraint: It allows null value.
50. How can u find out, a table is cost based optimization or rule based optimization?
Analyze table <table_name> compute statistics
51. What is SDLC process?
SDLC process is Software Development Life Cycle. In oracle it is called System
Development Life Cycle.
52. Can u have null value in foreign key constraint?
Yes, We can have null value in foreign key constraint.
53. Write a query to display row number and all columns.
Select rownum,emp.* from emp;
54. What are the different types of parameters?
In parameter, Out parameter and In-out parameter.
55. What is the difference between VB and D2k?
1. D2k is Oracle Corporation product.
2. But VB is Microsoft Product.
56. What is the use of NOCOPY parameter in oracle procedure?
Nocopy parameter is a compiler hint. Nocopy parameter pass parameter by reference.
57. How do you count total no of records from two tables if no relation between both tables?
Select a.b+c.d from (select count(*)b from emp)a, (select count(*)d from dept)c
58. What is LOB?
LOB is a data type.

59. What is syntax for procedure and functions?


Procedure:
create or replace procedure<procedure-name> [parameter list] is
(local declaration)
begin
(executable statements)
[exception]
(exception handlers)
end;

Function:
create or replace function<function name> [argument]
return datatype is
(local declaration)
begin
(executable statements)
[exception]
(exception handlers)
end;
60. What are parameters? Explain each.
In parameter
: Passes a constant value from the calling environment into the
procedure.
Out parameter
: Passes a value from the procedure to the calling environment.
In -Out parameter : Passes a value from the calling environment into the procedure
and a possibly different value
from the procedure back to the calling environment using the
same parameter.
61. How the view will be stored in the database?
The view will be stored in the database as query.
62. If any possibilities to return more than one value using sql function?
Yes, Function will return more than one value.
63. What are the schema objects?
Schema objects are tables, views, sequences, synonyms, indexes, clusters, procedures, functions,
database triggers and database links.
64. What is the different between oracle 8.0 and oracle 8i version?
(a) Cube operator is available in oracle 8i.
But cube operator is not available in oracle 8.0.
(b) Rollup operator is available in oracle 8i.

But rollup operator is not available in oracle 8.0.


(c) We can drop a column in oracle 8i.
We can not drop a column in oracle 8.0.
(d) We can use internet in oracle 8i.
We can not use internet in oracle 8.0
65. What is synonym? And its type.
Synonym is an alias. It has two types.1.Private synonym 2.Public synonyms.
66. What are clusters?
Clusters are groups of one or more tables.
67. What are the set operators?
Set operators combine the results of two queries into one result. They are union, union
all, intersect and minus.
68. What is difference between union and union all?
Union returns all distinct rows selected by either queries. Union all returns all rows selected by
either query including all duplicates.
69. Is there any restrictions to write sub query?
Yes.
70. What is output of following query?
Select(sysdate+null) from dual
Ans: Null.
71. Select null from dual where null=null?
Ans: No rows selected
72. What are the attributes of rowid?
18 characters long, unique, alphanumeric.
73. Where you can declare exception? Is declaration section or exception section?
Declaration section.
74. How do you trap error in oracle?
Using error handler.
75. How many types of cursor used in pl/sql? What are they?
(1) Implicit cursor- SQL CURSOR
(2) Explicit cursor
(a) Static Cursor
(b) Dynamic cursor
(c) Ref cursor

76. What are types of REF cursor?


(1) Strong cursor.
(2) Weak cursor.
77. What are explicit cursors attributes?
%found, %not found, %row count, %isopen
78. What is force view?
Force view is a view which is created without base table.
79. Can you create package body without package specification?
No, We can not create package body without package specification.
80. What are the features of oracle 9i?
1. Nullif: It will return null if expression1 and expression2 are equal. It will return expression1 if
expression1 and expression2

are not equal.


2. Case: It will return selected result.
3. NVL2: It will return null if expression1 is null. It will return expression1 if
expression1 is not null.
4. Coalesce: It will return first not null expression in the list.
5. Multi-level collection: It is nothing but collection of collection.
81. What is materialized view? Why are you using materialized view?
Materialized view a database object which stores results of local database table.
Advantages:(a) Summarizing data.
(b) Pre-computing data
(c) Replicating data.
(d) Distributing data
(e) Faster access for complex joins
(f) Transparent to end-users
Disadvantages:(a) Performance costs of maintaining the views. (b) Storage costs of maintaining the
views
82. Can you declare default value in IN, OUT and INOUT parameter?
Yes, We can declare default value for IN and INOUT parameters.
Example: procedure_name(p1 in varchar2(30) default Testing,
P2 inout varchar2(30) default Testing)
83. What are advantages of trigger?
(a) Replication(Disaster Recovery)
(b) General purpose.
(c) Auditing(To find who creating a trigger)
(d) Referential integrity.

84. What is pl/sql table?


PL/SQL table is like array in c.
85. What is pl/sql record?
PL/SQL record is like structure in c.
86. Can u create two procedures of same name in a package?
Yes, We can create two procedures of same name in a package(overloading)
87. Why do you create local and global index?
We create local and global index only for partitioned tables.
88. Why are you creating the index?
To fetch record very fastly.
89. What are types of index?
Index can be classified into two types. They are Unique index and Non-Unique index.
1. Unique Index.
(a) Primary key index and Unique index.
2. Non-Unique Index.
(a) Functional index.
(b) Lob index.
(c) Bit map index.
(d) B-Tree index.
(e) IOT(Index organized Table)
(f) Reverse index.
(g) Object index
(h) Partition Index.
90. Can you update base table using view?
Yes, We can update base table using view.
91. How many level of triggers are there in oracle?
1.Row level triggers
2.Statement level triggers
92. What is correlated subquery?
Is a subquery which is executed once for every row processed by outer query.
93. What is the use of instead of update triggers?
Update complex view.
94. What is oracle instance?
Oracle instance is combination of background process and system global area is known
as oracle instance.

95. If you use null with any arithmetical operation what will be output?
0, null, 1, none of the above.
Ans: null
96. Which one is true?
The LOB can be a user-defined data type
Is a table should have only one LOB
Ans: The LOB can be a user-defined data type.
97. Which one of the following is true in ADD_MONTH function in oracle?
Can we have negative number in second parameter?
Can we have integer in the first parameter?
Ans: Yes, We can have negative number in second parameter.
98. Consider the function, suppose the second value is greater than the first value what will be
output?
It will return negative value
It will return positive value
It will return the correct number of month left.
Ans: It will return negative value.
99. What is the maximum length of CHAR in oracle?
2000, 245, 4000
Ans: 2000 bytes.
100. What is the maximum length of VARCHAR2 in oracle?
2000, 245, 4000, None of these.
Ans: 4000 bytes.
101. What is the use of LENGTH function in oracle?
LENGTH function is used to find the length of a string.
102. Can you use VSIZE function in function or procedure?
Yes, We can use VSIZE function sql functions.
103. Which one is used to rename a table in oracle?
Rename, Alter command, both, either.
Ans: Rename
104. What are stands for OFA?
Optimal Flexible Architecture
105. What are the uses of last day and next day function?
Last_day function returns date corresponding to the last day of the month.
Next_day function returns date of specified day according to the sysdate.
Example:
SQL> select last_day(sysdate) from dual;

SQL> select next_day(sysdate,'monday') from dual;


106. How do you mask irrelevant data from users?
Synonyms, view, sequence, partitions, none of these.
Ans: Synonyms
107. Can you put '+' operator both side of outer-join?
Ans: No, We can not put '+' operator both side of outer-join.
108. Which one is correct for LPAD?
Blankspace," ",****,all;
Ans: all
555. Can you delete base table using view?
Yes, We can delete base table using view.
110. Select first maximum salary, second maximum and third maximum of emp table
First maximum : select max(sal) from emp;
Second maximum: select max(sal) from emp where sal<(select max(sal) from emp);
Third maximum : select max(sal) from emp where sal<(select max(sal) from emp
where sal<(select max(sal) from emp))
111. Give Codd's rules.
1. The information rule.
2. The rule of guaranteed access.
3. The systematic treatment of Null values.
4. The database description rule.
5. Comprehensive data sub language.
6. The view updating rule.
7. The insert and update rule.
8. The physical independence rule.
9. The logical data independence rule.
10. The integrity independece rule.
11. The distribution rule.
12. The non-subervision rule.
112. Write a query to display all records of emp table and rowid.
Select rowid,emp.* from emp;
113. Write a query to display rownum, rowid from emp table.
Select rowid, rownum from emp;
114. Write a query to select 5 highest paid employees from the emp table the month between jan
to march.
Select sal from(select sal from emp where hiredate between '01-jan-80' and '31-mar-80'
order by sal desc) where rownum<=5;
Note: Here (select sal from emp where hiredate between '01-jan-80' and '31-mar-80' order
by sal desc) is a inline view.

115. If you use null with any arithmetical operation what will be the output?
(a)0,(b)null,(c)1,(d)none of these.
Ans: null.
116. Write a query to display maximum salary for every department of a table.
Select * from emp where sal in(select max(sal) from emp group by deptno);
117. Write a query to display minimum salary for every dept within a table.
Select * from emp where sal in(select min(sal) from emp group by deptno);
118. Write a query to display average salary for each department.
Select deptno,avg(sal) from emp group by deptno;
119. Write a query to display the employee who earns a salary that is higher than the salary of
clerks. Sort the results by salary from
highest to lowest.
Select ename, deptno,job from emp where sal>all (select sal from emp where job
='CLERK')
Select ename, deptno,job from emp where sal>all (select sal from emp where job
='CLERK') order by sal desc;
119. Write a query to dispaly the alternate rows.(Odd records)
Select ename from(select ename,mod(rownum,2)r from emp) where r=1;
120. Write a query to display the alternate rows.(even records)
Select ename from(select ename,mod(rownum,2)r from emp) where r=0;
121. Write a query to select details of those persons whose sal is repeated?
Select ename,sal from emp where sal in(select sal from emp group by sal having
count(sal)>1);
122. Write a query to select the name of managers who manage more than one employee.
Select mgr from emp group by mgr having count(*)>1;
123. Which DML command does not support PL/SQL?
Explain plan.
124. Write a query to count the rows in two tables and display them in a single row.
Select a, b, a+b from(select count (*)a from emp),(select count(*) b from dept);
125. Write a query to select the Nth highest salary from emp table. (Using Connect by prior)
Select level, max(sal) from emp where level=1 connect by prior sal > sal group by level;
126. Write a query to display rows between nth row and mth row.
Select * from emp where rownum<&a minus select * from emp where rownum<&b;

127. At a time can u update more than one column values of a table? What query?
Yes, it is possible to update more than one columns values.
update tests set place='karaikudi',job='acct' where name='anbu';
update tests set place='unjanai',job='clerk',age=25 where name='anna';
128. Can u use cursor in trigger?
Yes.
129. Write a query to use where,group by,order by and having clauses are using at a time.
Select job,sum(sal) from emp where job not like 'SALESMAN%' group by job having
sum(sal)>5000 order by sum(sal);
130. Write a query use 'in' clause.
Select ename,sal,deptno from emp where sal in(select min(sal) from emp group by
deptno);
131. Write a query use 'any' clause.
Select empno,ename,job from emp where sal<any(select sal from emp where
job='CLERK') and job<>'CLERK';
132. Write a query use 'all' clause.
Select empno,ename,job from emp where sal>all(select avg(sal) from emp group by
deptno);
133. Write a query to display the records of emp table where comm is null.
Select * from emp where comm is null.
134. Write a query to drop a column of a table.
Alter table <table name> set unused column <column name> (OR) alter table <tablename> drop column <column_name>
135. Write a query to disable the constraint.
Alter table emp disable constraint emp_empno_pk cascade;
136. Write a query to display top-n salary.
Select rownum as rank,ename,sal from (select ename,sal from emp order by sal desc)
where rownum<=3;
137. Define Transaction?
A Transaction is a logical unit work that comprises one or more SQL statements executed
by a single user.
138. What are the different types of views are there?
1. Force view - To create a view without base table.
2. Inline view - To find top-n salary

3. Materialized view - To store result of local database table.


4. Complex view - To create a view from multiple tables.
5. Read only view - To view read only purpose.
139. Delete and truncate. Here which command to take less time to execute?
Truncate command take less time to execute.
140. How do you display 5th line of a procedure?
Select text from user_source where name='SAMPLE' and line=5;
141. What is OLTP?
The Online Transaction Processing (OLTP)
142. What files are used in the Oracle instance?
1. Data files
2. Redo log files
3. Control files.
4. Parameter file.
143. What is difference between instring and substring?
INSTR(string,char)
INSTRING returns location of a string according to specified character.
Example: Select ename, instr(ename,E) from emp;
ENAME
INSTR(ENAME,'E')
SMITH
0
ALLEN
4
WARD
0
JONES
4
SUBSTR(String n,m)
SUBSTR returns a substring according to specified position.
Example: Select ename,substr(ename,2,4) from emp;
ENAME
SUBS
SMITH
MITH
ALLEN
LLEN
WARD
ARD
JONES
ONES
144. What is SQL*Net? What is use of SQL*NET?
SQL*Net is Oracle's communication protocol. SQL*Net uses various network
communication protocols such as TCP and IP
145. What is difference between char and varchar2?
CHAR pads blank spaces to the maximum length. VARCHAR2 does not pad blank spaces.
146. What is SQL*Loader? What are contents of sql*loader?

SQL*Loader is Oracle utility that is used for loading data into an Oracle database.
SQL*Loader accepts two input file types:- The input data file and control file.
147. An emp table contains 100 records. First 40 records are columns one male and remaining 60
records are columns are female.
Using single statement can you change male to female and female to male?
(1) Update empmale a set sex = (select case sex when 'female' then 'male' else 'female' end
from empmale b
where a.empno = b.empno)
(2) Update empmale a set sex = (select decode(sex,'male','female','female','male') from
empmale b
where a.empno = b.empno)
148. What operators are using in sub queries operators?
(a) Any
(b) All
(c) In
(d) Some
(e) Exists
149. Write about Explicit cursor attributes.
%Found
:To check whether cursor has fetched any row. True if rows are
fetched.
%Not Found :To check whether cursor has fetched any row. True if no rows are
fetched.
%Rowcount :To count the number of fetched or updated or deleted rows.
%Isopen
:To check whether cursor is opened or not.
150. What are logical files?
Redo log files, Control file and Data file.
151. Tell about NVL2 function.
NVL2 function return expression2 if expression1 is not null, return expression3 if
expression1 is null.
Syntax:NVL2(string1, value if not null, value if null)
Ex:
Select nvl2(supplier_city, completed, n/a);
152. What is null?
Null is inapplicable. Neither space nor zero where column is not null. Null is an
inaccessible.
153. What is Dual table?
Dual is a dummy table is created by oracle server which has one row and one column.
154. Can you create view without base table?

Yes, We can create view without base table.


155. What are the different types of OUTER JOINS?
LEFT OUTER JOIN, RIGHT OUTER JOIN
156. Why are you using constraints?
Constraints prevent invalid data entry into table.
157. Can you call cursor in stored function and stored procedure?
Yes, we can call cursor in stored function and stored procedure.
158. How many normalization is there? What are they?
Totally 3 normalizations only.
1. Avoid Redundancy
2. Functional Dependency.
3. Transient Dependency.
159. What query used to display a particualr index?
Select * from user_indexes where index_name='AK'
160. Can you write to display records between two dates without any error?
Yes, we can display records between two dates without any error.
Select * from emp where hiredate between '17-DEC-80' and '23-JAN-82';
161. What is decode?
Decode means internally if selection logic.
162. What is isolation?
Delete the parent record, if child record is present.
163. What is nvl function?
To assign a value to null field.
Nvl(expression1,expression2)
(1) If expression1 is null, nvl function returns expression2.
(2) If expression1 is not null, nvl function returns expression1.
(3) Expression1 and Expression2 are different data types oracle converts expression2 the
data type of expression1.
164. What is system table space? When it will be created?
Every oracle database contains tablespace which named System tablespace. It is created
automatically
when the database is created.
165. Difference between public procedure and private procedure.
Public procedures can declare in package specification and also we can use anywhere in
package. But private procedure can be declared in package body and we can use this package
part only. So this is called private procedure.

166. What is schema?


Schema is a collection of database object of a user.
167. Can you create trigger for view?
Yes, We can create triggers for view.
168. How can you see all triggers?
Select * from user_triggers
169. In which modes are pass by reference and pass by value in the following parameter modes.
IN parameter Pass by reference
OUT parameter Pass by value.
169. What is query for the following output?
26-APR-2006 12:30:20
Ans: select localtimestamp from dual;
170. What is the output for the following query?
Select null+80*100+200*240 from dual; Ans: Null
171. If you drop the view, is it possible drop the corresponding base table at the same time?
No, Base table is not dropped only view is dropped.
172. Write about Exists operator.
The Exists operator is frequently used with correlated subqueries. It tests whether a value
is there. If the value exists it returns
True; if it does not exists it returns False.
Select empno,ename,job,deptno from emp e where exists(select empno from emp where
emp.mgr=e.empno) order by empno
173. Select empno,ename,sal from emp where sal between 2000 and 3000 and select
empno,ename,sal from emp
where sal>=2000 and sal<=3000 give same results.
174. Can you create index on primary key column of a table?
No, We can not create index on primary key column in a table.

175. Select max(sal),min(sal),avg(sal),sum(sal) from emp;


MAX(SAL) MIN(SAL) AVG(SAL) SUM(SAL)
------------------------------------5000
800
2108.92857
29525
176. Select round(max(sal))/2,round(min(sal))/2,
round(avg(sal))/2,round(sum(sal))/2 from emp;

ROUND(MAX(SAL))/2 ROUND(MIN(SAL))/2 ROUND(AVG(SAL))/2


ROUND(SUM(SAL))/2
-----------------------------------------------------------------------------------------------------------2500
400
1054.5
14762.5
177. What are levels of System Development Life Cycle process?
1. Strategy and Analysis
2. Design
3. Build and Document
4. Transition
5. Production
178.

Table of first;
C1
C2
---------- ---------1
2
3
4

Table of second;
D1
D2
---------- ---------5
6
7
8
What is result of this query? Select e.*, d.* from first e, second d;
Select e.*,d.* from first e, second d;
C1
C2
D1
D2
------ ---------- --------- ---------1
2
5
6
3
4
5
6
1
2
7
8
3
4
7
8
179. Can you create synonym for procedure, function and package?
Yes, We can create synonym for procedure, function, package and triggers.
180. Can you update view it affects base table?
Yes, It affects base table.
181. What is difference between public synonym and private synonym?
Public synonym can be accessed by any user on the database.
Private synonym can be accessed by only by the owner.
182. When invalid_number exception raise?

This exception is raised if the conversion of a character string to a number fails because
the string does not represent a valid number. For example, inserting john for a column of type
number will raise this exception.
183. 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.
184. When we created function or procedure which code is stored in the database?
(a)p-code
(b)source code
(c)p-code and source code
(d)None
Ans: Source code
185. What are PL/SQL Cursor Exceptions?
Cursor_already_open, Invalid_cursor
186. What is difference between view and synonym?
View is a database object that logically represents one or more database tables. Synonym
is a database object, which physically represents a table with different name.
187. What is function?
A function is a pl/sql block that computes a value.
188. What is procedure?
A procedure is a pl/sql block that performs a specific action.

189. What is PL/SQL?


PL/SQL is a structured language block and can be divided into three parts are a declarative part,
an executable part and an exception part.
190. What is view?
A view is a virtual table.
191. Can you update complex view?
Yes, We can update complex view
192. Write a query using cube and roll up operator.
Select deptno,job,sum(sal) from emp group by rollup(deptno,job);--------Roll up
operator.
Select deptno,job,sum(sal) from emp group by cube(deptno,job); ---------Cube operator.

193. One table has 4 rows, 5 columns and another table has 3 rows and 4 columns, what result
will come how many rows and how
many columns?(use carteasian product)
It will display 12 rows and 9 columns.
194. How do you display current value of sequence?
Select ss.currval from dual;( Here ss is a sequence)
195. What is global temporary table?
Global Temporary table is a Session based table.
196. How do you run a procedure in sql prompt?
We can run a procedure in sql prompt using EXECUTE command.
197. How do you increase the speed of execution by a query?
We increase the speed of execution by a query using query optimization.
198. Write query to find experience of all employees in months.
Select months_between(sysdate,hiredate) employees_emperience from sample_emp;
EMPLOYEES_EMPERIENCE
-------------------------------------98.0542522
38
74
60.989736
83.957478
2.37683281
199. Tell about predicates.
A predicate is a search condition. A predicate uses operators, expressions, and constants to
specify the search condition. The main predicates are RELATIONAL, BETWEEN, NULL,
EXISTS, LIKE and IN. Predicates are using in a HAVING or WHERE clause.
200. What is difference between sql and sql*plus.
(1) Standard
(2)To table with database
(3)Standard query lanuguage
(4)We can abbrevate SQL statements.-

Oracle preparating.
Used for formatting purpose.
Environment.
We can abbrevate the statements.

201. What are Oracle utilities?


SQL*Loader :- This is Oracle utility that is used for loading data into an Oracle
database. SQL*Loader is designed to be
flexible and to accept data in a variety of formats.
Export
:- This program stores Oracle data and table definitions externally in an
Oracle-specific binary format.
Import
:- This program loads data into the database from an Oracle export file.

202. What is deadlock?


When two user attempts to perform the actions that interface with one another the
situation is defined as deadlock.
203. Which date function returns number value?
Months_between. This date function takes 2 valid dates and returns number of months in
between them.
204. When will you need create an index for a table?
1. The column contains a wide range of values.
2. The column contains a large number of null values.
3. The column is used frequently in the where clause or in a condition.
4. Two or more columns are frequently used together clause or a join condition.
205. When we add any data to the table, What happened in rowid and rownum?
When we add any data to the table, the rowid and rownum will be incremented.
206. What is difference between subquery and correlated subquery?
Subquery is a query which is executed once for entire parent statement. Correlated subquery is a
subquery which is executed once for every row processed by outer query.
207. If u create a foreign key through a master table, primary column name of master table and
foreign key column name of detail
table must be same name or not?
No, Need to be same name, they may be different name.
208. Write code for using cursor with parameter? (Parmeterized cursor)
To display the details of employees belonging to department no 10 getting
salary>5000.
declare
cursor c1(p1 number) is
select empno,ename,sal,deptno from semp where deptno=p1;
currec c1%rowtype;
begin
open c1(10);
loop
fetch c1 into currec;
if c1%found then
if currec.sal>5000 then
dbms_output.put_line(currec.empno||' '||currec.ename||' '||currec.sal||' '||currec.deptno);
end if;
else
exit;
end if;

end loop;
close c1;
end;
209. Tell about connect by prior.
We can use connect by prior,retrieves rows in hierarchical order.
Ex: Select level, max(sal) from emp where level=2 connect by prior sal > sal group by
level
210. Write query list the names of employees, who are more than 5 years old in the organization.
Select ename from emp where(sysdate hiredate)>(5*365);
211. Write all employees who have at least one person reporting to them.
Select empno,ename,job,deptno from emp e where exists(select empno from emp where
emp.mgr=e.empno)
order by empno;
212. Write a query to create a table from another table without duplicate rows.
Create table bb as select distinct * from b;
213. Write a query to count different data values in a column.
Select
deptno,sum(decode(job,'CLERK',1,0))
CLERKS,sum(decode(job,'MANAGER',1,0)) MANAGERS,
count(decode(job,'CLERK',1,'MANAGER',1)) TOTAL FROM EMP GROUP BY
DEPTNO;
214. Can you do DML operations for synonyms of table?
Yes, We can do DML operations for synonyms of table.
215. Can you set primary key for whole table?
Yes. We can set primary key for whole table.
556. Can u use more than one return type in stored function?
Yes, We can use more than one return type in stored function.
217. Tell about segment.
A segment is a set of extents allocated for a certain logical structure.
218. What is output of this query?
Select count(*) from emp;
Select count('abc') from emp;
Select count('a1b1c1') from emp;

Output: 14
Output: 14
Output: 14

219. What is the maximum SIZE allowed for each type?


The Maximum Size is up to 32.

220. What are uses of nested tables?


Nested tables are syntactically array in c.
221.

(a)select * from table


(b)Select col1 from table
(c)Select col1, col2 from table.
(d)Select col1, col2, col3 from table.
Here which query take less time to execute or which one executes fast?
Select col1 from table.

Ans:

222. What is output of this query? Select 1 from dual union select a from dual.
OUTPUT: ERROR at line 1:
ORA-00904: "A": invalid identifier
223. What is output of this query? Select * from emp where rownum<=10.
It will display first 10 records.
224. What is output of this query? Select * from emp where rownum<10
It will display first 9 records.
225. Number, Number (4,2),Number(6). Here Number(i.e,first one) data type can accept decimal
or not?
ANS: Yes, Number data type can accept decimal number.
226. Write a query to display three employees records are having equal salaries.
Select * from megus where sal=all(select sal from megus where sal=17500);
(OR)
Select * from megus where sal in(select sal from megus where sal=17500)
227. Write a query to display even records (All columns) from emp table.
Select
empno,ename,job,mgr,hiredate,sal,comm,deptno
empno,ename,job,mgr,hiredate,sal,comm,deptno,
mod(rownum,2)a from emp) where a=0;
228. Write a query to display odd records (All columns) from emp table.
Select
empno,ename,job,mgr,hiredate,sal,comm,deptno
empno,ename,job,mgr,hiredate,sal,comm,deptno,
mod(rownum,2)a from emp) where a=1;

from(select

from(select

229. Explain Modularity, Reusability and Maintainablity.


Modularity:Subprograms allow us to break a program into manageable, well
defined logical modules.
Reusablity:Subprograms once executed can be used in any number of
applications.
Maintainablity:Subprograms can simplify maintenance, because if a subprogram
is affected, only its definition changes.
230. What is size of Number data type?

ANS: 38 digits
231. What is the fastest way of accessing a row in a table?
Using ROWID
232. Write a query top-n salary for all columns.
Select * from(select * from emp order by sal desc) where rownum<=3
233. Which one is the oracle statement?
a)ordered
b)group by
c)NDEX
d)All_rows
Ans: b
234. In SQL function for emp table of hiredate column which three statements are correct.
(a)select count(hiredate) from emp
(b)select avg(hiredate) from emp
(c)select max(hiredate) from emp
(d)select sum(hiredate) from emp
(e)select min(hiredate) from emp
ANS:- a, c, e
235. Which of the following column is a pseudo column?
(a)curval
(b)Rowid
(c)next val
(d)Add_month
ANS:- a, b, c.
236. Which one command is /SQL*PLUS command?
(a) insert
(b) update
(c) delete
(d) select
(e) describe
(f) rename
ANS:- e.- describe.
237. What happened to a view, when the base table is altered?
We dropped one column from base table it will display the following output came.
ANS:- view "SCOTT.ONE_SS" has errors.
238. Select first.currval from sys.dual.What is output of this query?
(a)it will display current value of index.
(b)it will display current value of sequence
(c)it will display current value of view

(d)it will display error.

ANS: b

239. Select ename from emp where ename like _A% What is result of this query?
ENAME
---------WARD
MARTIN
JAMES
240. What is difference between rename and alias?
Rename is a permanent name given to a table or column whereas Alias is a temporary name
given to a table or column which does not exist once the SQL statement is executed.
241. How can you import from text file to database? Which command using?
We can import from text file to database through TOAD tool using IMP command.
242. Why are you creating trigger for view?
We create trigger for view update the complex view.
243. Can a view contain any data?
No, A view does not can contain data.
244. Tell about public procedure and private procedure.
Package Specification.
Package Body.
Procedure x
Procedure x
Procedure y
Procedure y
Procedure z
Procedure z
Procedure s
Procedure k
Here we declared Procedure x, procedure y and procedure z.(Package specification part) We can
use anywhere in the modules of project. So this is called Public procedure. We declared
procedure s, and procedure k(Package Body). We can use this part only. We can not use in the
modules of project. So this is called Private procedure. That is package specification part is
called Public Procedure and package body is called Private Procedure.
245. Can you update the complex views?
Yes, We can update in complex view.
246. How do you run a procedure in sql prompt?
We run a procedure in sql prompt using Execute command or run command.
Example:- Execute <procedure name> (OR) Run or Start <path name> ex:
c:\sample.sql;
247. In cost based optimization, what is meaning of 'cost'?
Cost means execution time

248. Write query for second maximum salary. Which part is first executed?
Select max(sal) from emp where sal<(select max(sal) from emp); Here main query is
executed first.
249.

procedure 1 int x
procedure 2 (that is y=x)
procedure 3
(Here can we call the variable x from procedure 1 to procedure 2 i.e)y=x and can we call
variable x to procedure 3)
ANS: No, We can not call variable x from procedure 1 to procedure 2 and procedure 3.
250. If i want to see your data? How can i see that?
Username.Object.
251. We declared three procedures in the package specification section. But we used only two
procedures in the package body. Will it
show Errors? Ans: No, It will not show error.
252. How can you link two tables without foreign key?
Using join we can link two tables.
253. What is external file?
We use except database file is called external file.
254. What can be the maximum size of PL/SQL block?
Select * from dba_object_size where name = 'procedure_name';
255. We declared two procedures in the package specification. But we implemented three
procedures in package body. It will show
error or not? Ans:- No, It will not show error.
256. How do you display particular information from procedure?
Using DBMS_OUTPUT.PUT_LINE
257. Tell about System Global Area(SGA)
* A group of shared memory structures.
* The information stored within an SGA is divided into several areas of memory.
(1) The database buffer cache.
(2) The Redo Log buffer.
(3) The shared pool
(4) Request and response queues (if multithreaded server is used)
(5) Other miscellaneous information.
258. If any syntax error in insert statement, values are inserted or not.
No, The values are not inserted.
259. What are implicit cursors attributes.

1. Sql%found
2. Sql%not found
3. Sql%rowcount
4. Sql%isopen.
260. Oracle database structure.
* A database is a collection of data files and programs that manipulate those data files.
* Two types of information are stored in an oracle database:
(1) User data, relevant to a particular application
(2) System data, which the database needs to manage itself.
* Components.
(1) Database file
: These are Operating System files and contain all the
database data.
(2) Control file
: Contain information that is required by the RDBMS to
access and manipulate the data.
(3) Redo Logs file
: These files record all the transaction on the database.
(4) Tablespaces
: A database is divided into logical units called tablespaces.
(5) Segments
: A segment is a set of extents allocated for a certain logical
structure.
(6) Extents
: An extent is a specific number of contiguous data blocks,
obtained in a single allocation,
used to store a
specific type of information.
261. When %found is true.
%Found
:fetched.

To check whether cursor has fetched any row. True if rows are

262. Write a query to count all jobs and employees different data values in a column.
select deptno,sum(decode(job,'ANALYST',1,0))ANALYSTS,
sum(decode(job,'CLERK',1,0))CLERKS,
sum(decode(job,'MANAGER',1,0))MANAGERS,
sum(decode(job,'PRESIDENT',1,0))PRESIDENT,
sum(decode(job,'SALESMAN',1,0))SALESMANS,
count(decode(job,'ANALYST',1,'CLERK',1,'MANAGER',1,'PRESIDENT',1,
'SALESMAN',1)) TOTAL from emp group by deptno
263. Which case we use a FULL OUTER JOIN?
We want all unmatched data from both tables.
264. What is Inline view?
A subquery in from clause of a select statement is called Inline view.
265. Draw the Entity Relationship (E-R) diagram.

NAME

SYMBOL

Entity

FUNCTION

Data object in the system unique


identifiable by identifier has attr
that describe it.

Attribute
Relationship

Describes an entity.
Relates two entities uniquely
Identified By the identifier.

266. How can you add not null constraint into a table? Say the syntax.
At first To add a column with NOT NULL constraint, the table must be empty.
Alter table <table_name> modify <column_name data type(size)> not null;
Example:- Alter table test modify no number not null;
267. Difference between inner join and outer join
Inner join:- Joining the table with itself.
Outer-Join:- Join has done between two tables.
268. If you dropped a table corresponding index is dropped or not?
Yes, index also dropped.
269. If you dropped a table corresponding constraint is dropped or not?
Yes, constraint also dropped.
270. Tell about snapshot.
A snapshot is a table that contains the result of query of one or more tables or views
located on a remote database.
271. Tell about savepoint
Savepoints are like markers to divide a very lengthy transaction into smaller ones. They
are used to identify a point in a
transaction to which we can later rollback. It enables rolling
back part of a transaction. Maximum five save points are allowed.
272. How do you transfer the data from a excel table to sql table.
TOAD atmosphere is a tool. We can do all activities as such like that oracle.
273. How much maximum arguments can you pass in parameter list of procedure?
2100
274. Can you do DML operations in PL/SQL procedure?

Yes, We can do DML operations in PL/SQL in procedure.


275. What is the default percentage of PCTUSED and PCTFREE in a table?
60 and 40.
276. Tell about equi-join,non-equi-join,outer-join.
Equi-Join:Joining two tables by equating two common columns.
Non-Equi-Join:Joining two tables based on condition other than equating two
common columns.
Outer-Join:Join two tables in such a way that query can also retrieve rows that
do not have the corresponding join
value in the other table.
Self-Join:Same table with different alias.
277. Write syntax for creation of foreign key constraint and alteration of foreign key constraint.
Creation of foreign key constraint:Create table <table_name>(col1 data type references <table_name>(column_name)
Example:Create table test4(emp_no number(6) references test3(emp_no)
Alteration of foreign key constraint:Alter table <table_name> add constraint <constraint_name> foreign key<column_name>
references<table_name><column_name>;
Example:Alter table b_detail add constraint jj foreign key(no) references
a_mast(no);
Alteration of On-Delete-Cascade constraint:Alter table order_master add constraint fk_code foreign key(vencode) references
vendor_master(vencode)
On delete cascade;
278. The following procedure will be executed or not? If is it not executed what error will
throw?
Declare
vname emp.ename%type;
Begin
select ename into vname from emp;
end;
ANS:- It will not executed. It will throw exact fetch returns more than requested
number of rows
279. What are types of partition?
(a) Range partition.
(b) Hash partition.
(c) Composite partition.
280. Write query for the following output:DEPTNO
MALE FEMALE TOTAL

---------------- ------------------10
1
2
3
20
1
1
2
30
1
1
2
select deptno,sum(decode(sex,'male',1))male,sum(decode(sex,'female',1))female,
sum(decode(sex,'male',1,'female',1))Total from b_mast group by deptno;
281. Is it possible to allow five columns in pl/sql table?
Yes, It is possible to allow five columns in pl/sql table.
282. What is partition?
A single logical table can be split into a number of physically separate pieces based on
ranges of key values.
283. Why do you make table partition?
(a) To implement very large tables in data warehouse environments.
(b) To support parallel execution of insert, delete and update operations.
(c) To manage database availability.
(d) To perform administrative tasks incrementally.
284. What are restrictions of Cursor Variables?
(a) Remote subprograms can not return the value of a cursor variable.
(b) PL/SQL tables can not store cursor variables.
(c) Cursor variables can not be used with dynamic SQL in Pro*C.
(d) The query associated with a cursor variable in the OPENFOR statement.
285. Write syntax for creation of partition.
Create table <table name> (column name data type, column name data type,..) partition
by range(column name)
(partition <partition name> values less than <value>, partition <partition name> values
less than <value>);
Example:Create table vendor_detail(orderno varchar2(5),
odate date,
vencode varchar2(5),
o_status char(1),
del_date date)
partition by range(orderno)
(partition om1 values less than('o010'),
partition om2 values less than('o020'));
286. What is a mutating table?
A mutating table is a table that is currently being modified by an update, or a delete or an
insert statement.

287. After inserted values into a table, we give rollback after then commit. The values are
inserted or not.
The values are not inserted.
288. To find the total amount of each sales person which should be more than the maximum
amount for the following table?
SNAME
AMOUNT
A
4000
B
2000
A
2000
C
3000
C
2000
B
2000
Select sum(amount) from stable having sum(amount)>(select max(amount) from
stable)group by sname;
289. What are advantages of PL/SQL?
(a) Support the declaration and manipulation of object types and collections
(b) Allows the calling of external functions and procedures.
(c) Contains new libraries of built-in packages.
(d) Support for SQL.
(e) Higher productivity
(f) Better performance
(g) Portability (h) Integration with oracle
290. One table is created using create command, after we will not give commit statement. Table
is stored or not.
Table is stored. Because DDL commands are automatically committed.
291. What is difference between view and table?
(1) A view does not have own data. But a table have own data.
(2) A view is a virtual table but table is real table.
(3) We can not truncate the view but we can truncate the base table.
292. Give name for implicit cursor?
Ans: Sql cursor is a implicit cursor.
293. Synonym occupies any table space?
Yes, Synonym occupies table space.
294. {
{
{
{
{

}
}
}
}
}
We wrote a procedure like this. At the compile time it will show error at third loop. But third
loop is not a program, that is a
comment line. Next time the control, where it will be go.
Ans: It will go to previous loop.
295. View occupies any table space?
No, View does not occupy any table space.
296. What is Query optimization?
Query optimization is the process of choosing the most efficient way to execute a SQL
statement.
297. What are types of Query optimization?
1. Rule based optimization.
2. Cost based optimization.
298. What are various joins used while writing subquery?
(a) Self-join (b) Equi-join (c) Outer join
299. What are analytical functions?
Rank, Dense_rank, Top_N, Cume_Dist, Percent_Rank and Row_Number
300. What are uses of synonyms?
1. Simplify SQL statements
2. Hide name and owner of object.
3. Provide location transparency for remote objects.
4. Provide public access to an object.
301. Can you truncate view?
No, We can not truncate view.
302. Select count(*),count(comm),count(null). What is output of this query? Here commission is
null.
SQL> select * from test;
COMM
10 rows selected.
SQL> select count(*),count(comm),count(null) from test;
COUNT(*) COUNT(COMM) COUNT(NULL)
----------------------------- ------------------10
0
0

303. How can u find out particular columns are indexed or not?
Select index_name, column_name from user_ind_columns where table_name='DEPT';
304. What is index cluster?
A cluster with an index on the cluster key.
305. What is Tablespaces?
A database is divided into logical units called tablespaces.
306. What is Collection?
A Collection is like that array.
307. Where procedure and function stored?
Data dictionary.
308. What are differences between varray and nested table?
1. Varry have a maximum size. But Nested Tables do not have an explicit maximum size.
2. When stored in the database, Varry retain the ordering and subscript values for the
elements. But Nested Tables
do not retain the ordering and subscript values for the elements.
309. What is candidate key?
A table is created without any key is called candidate key.
310. What are PL/SQL data types?
Boolean, binary_integer, number, character, raw, long raw, rowid and LOB
312. What are SQL data types?
Char, varchar2, number, date, raw, long, long raw and LOB
313. What are PL/SQL attributes?
%type and %rowtype.
314. What are types of triggers?
1. DML triggers
2. System triggers
3. Instead of triggers
315. What is pragma?
Pragma is a compiler directive.
316. Write a procedure code.
create or replace procedure item(orders varchar2) is
qtyhand number;
relevel number;

maxlevel number;
begin
select qty_hand,re_level,max_level into qtyhand,relevel,maxlevel from itemfile
where itemcode=orders;
if qtyhand < relevel then
update itemfile set qty_hand=relevel+qtyhand where itemcode=orders;
else
dbms_output.put_line('itemlevel ok');
end if;
exception
when no_data_found then
dbms_output.put_line('no data returned');
end;
317. Write a function code.
create or replace function itmes(it varchar2)
return number is
args number;
qtyhand number;
relevel number;
maxlevel number;
begin
select qty_hand,re_level, max_level into qtyhand,relevel,maxlevel from itemfile
where itemcode=it;
if(qtyhand+relevel)>maxlevel then
args:=maxlevel;
return args;
else
args:=(qtyhand+relevel);
return args;
end if;
end;
318. After deleted values into a table, we give truncate. What is output? The values are available
on the table or not.
Ans: The values are not available.
319. Which of the below data dictionary views will tell you whether a given procedure valid or
not.
(a)user_procedure B)user_object (c)user_object_status (d)user_source.
320. Write a package code.
Create or replace package body pack_me as
procedure order_proc(orno varchar2) is
stat char(1);

Begin
select ostatus into stat from order_master where orderno=orno;
if stat=p then
dbms_output.put_line(pending order);
else
dbms_output.put_line(completed order);
end if;
End order_proc;
function order_fun(ornos varchar2) return varchar2 is
icode varchar2(5);
ocode varchar2(5);
qtyord number;
qtydeld number;
begin
select qty_ord,qty_deld,itemcode,orderno into qtyord,qtydeld,icode,ocode
from order_detail
where orderno=ornos;
if qtyord<qtydeld then
return ocode;
else
return icode;
end if;
end order_fun;
end pack_me
321. How do u alter user?
Alter user hr identified by hr account unlock;
322. What are the IDEs used in your project?
Integrated Development Environment.

1. Toad Tool 2. Pl/sql developer.

323. Write a trigger code(Row level trigger)


create or replace trigger orders
before insert on order_detail for each row
declare
orno order_detail.orderno%type;
begin
select orderno into orno from order_detail
where qty_ord<qty_deld;
if orno=o001 then
raise_application_error(-20001, enter some other number);
end if;
end;
555. What is difference between simple view and complex view?
Simple view
Complex view

1. One table

1. More than one table.

553. Can you insert base table using view?


Yes, We can insert base table using view.
326. What are parts of a trigger?
1. Trigger Event
2. Trigger Constraint

3. Trigger Action

327. Can you do DML operation in read only view?


No, We can not DML operation in read only view.
328. What is use of Revoke command?
Revoke command can be used to return privileges.
329. Can u use package instead of procedure?
Yes, We can use package instead of procedure.
330. What is difference between unique index and composite index?
(a) By using unique index we can create index on single column of a table but using
composite index we can create index for
multiple columns.
(b) Unique index occupy more memory but Composite index occupy less memory.
331. What are uses of local and global indexes?
Local and Global indexes are used in partitioned tables.
332. What is oops concept?
OOPS concept is Object Oriented Programming System. It is a new way of organizing and
developing programs. It consists
of encapsulation, abstraction, polymorphism (overloading) and inheritance.
333. A view is created from multiple tables. How do u know tables of this view?
Select * from user_views; (through this query)
334. What is Overloading (Polymorphism)?
Polymorphism is a process of making an object to a variety of jobs.7
335. What are built-in package names?
1. DBMS_ALERT
2. DBMS_APPLICATION_INFO
3. DBMS_AQ & DBMS_AQADM
4. DBMS_DDL
5. DBMS_DESCRIBE
6. DBMS_LOB
7. DBMS_LOCK
8. DBMS_OUTPUT

9. DBMS_PIPE
10. DBMS_ROWID
11. DBMS_SESSION
12. DBMS_SHARED_POOL
13. DBMS_SQL
14. DBMS_TRANSACTION
15. DBMS_UTILITY
336. What are composite types?
Composite types are record, index by table, varray and nested tables.
337. What is Varray?
Fixed number of elements.
338. What is Nested table?
Nested table is like array in c.
339. What are non-schema objects?
Segments, extents, users, tablespaces, roles, profiles, contexts and directories.
340. What is redo log file?
Redo Logs

: This log file record all the transaction on the database.

341. Which parameter mode is default?


IN parameter mode.
342. What is difference between cycle and no cycle?
Cycle: Cycle generate values from the beginning after reaching either its maximum or
minimum value.
No Cycle: No Cycle does not generate values from the beginning after reaching either its
maximum
or minimum value.
343. What is output of this query: select substr('ambedkar',-1) from dual;
SQL> select substr('ambedkar',-1) from dual;
Output:S
R
344. Why we need rowid?
(a) Rowid is used to find duplicate records in the table.
(b) Rowid is used to give address for corresponding row.
(c) Rowid provides fastest way of removing data from the table.
551. What is use of bind variable?

Bind variable used to pass run-time values into pl/sql block.


346. Tell about when others exception.
This exception handler rather than defining a separate handler for every exception type.
This exception handler handles all
error not already handled in the block. This exception handler should always be the last
exception handler in the block. This exception handler is used to help to know what error has
exactly occurred.
347. You have a table in which 10 columns are there. In all the ten columns you have the index.
Which of the following is related to?
1. Insert values are faster.
2. Update values are slower.
3. Select operations can be done faster.
4. Delete operations can not be done.
Ans: Select operations can be done faster.
348. What is index?
Index is an optional structure associated with a table to have direct access to the rows which can
be created to increase the performance of data retrieval.
349. What is Data Dictionary?
The Data Dictionary of an Oracle database is a set of tables and views that are stored as a read
only reference about the database. It stores information about the logical and physical structure
of the database.
350. What is output of this query? Select count (1) from dual;
Ans: COUNT(1)
--------1
351. What is output of this query? Select 1 from dual;
Ans:- 1/1
352. What is output of this query? Select count('a') from dual
Ans:- COUNT('A')
---------1
353. What is output of this query? Select count(a) from dual
Ans:ERROR at line 1:
ORA-00904: "A": invalid identifier
354. What is output of this query? Select sysdate+0 from dual;
Ans:SYSDATE+0
---------------06-JUL-07

355. What is output of this query? Select 1 from dual union select a from dual;
Ans:- ERROR at line 1:
ORA-00904: "A": invalid identifier
356. What is output of this query? Select 1 from dual union select 1 from dual;
Ans:1
---------1
357. Can u use out and in-out parameter in function?
Yes, We can use out and in-out parameters.
358. What is difference between oracle 9i and 10g?
Here 10g g means grit computers.
We can not rollback the dropped table in oracle 9i. But we can rollback the dropped table
in oracle 10g.
359. What is difference between replace and translate?
Replace:- Replace returns char with every occurrence of search string replaced with replacement
string. Replace function replaces.
SQL> select replace('ambedkar','ed','rrrrrrr') from dual;
REPLACE('AMBE
------------Ambrrrrrrrkar
Translate:- Translate returns char with all occurrences of each character in from string replaced
by its corresponding character in to string.
SQL> select translate('ambedkar','ed','rrrrrrr') from dual;
TRANSLAT
--------------Ambrrkar
360. Write syntax for table creation.
(a) Create table <table_name>(column_name1 datatype(size),column_name2
datatype(size));
(b) Create table <table_name> as select <column_name> from <another_table_name>
361. What is difference between to_char and to_date function?
To_char function converts date to a value of varchar2 datatype.
(a) SQL> select to_char(sysdate,'ddth "of" fmmonth yyyy') from dual;
TO_CHAR(SYSDATE,'DDTH"
---------------------10th of july 2007

(b). SQL> select to_char(hiredate,'ddth "of" fmmonth yyyy') from emp where
empno=7369;
TO_CHAR(HIREDATE,'DDTH
---------------------17th of december 1980
To_date function converts char or varchar2 datatype to date datatype.
SQL> select to_date('january 27 1999', 'month-dd-yyyy') from dual;
TO_DATE('
--------27-JAN-99
362. Write query to display empname,comm from employee, if employee has no commission put
commission is empty.
Select ename,comm,nvl(comm,0) from emp;
363. One view is created from multiple tables, client how do you know columns of tables (Which
tables)
Select * from user_views;
364. Write a query who got more than the avg sal from emp.
Select * from emp where sal>all(select avg(sal) from emp group by deptno);
365. Write query to display employee name and empno, who are reporting to king.
Select a.empno,a.ename,b.empno,b.ename from emp a, emp b where a.mgr=b.empno and
b.ename='KING';
366. How do u find user name?
We find through show user.
367. What are RDBMS packages?
RDBMS packages are Oracle, Sybase, Ingress, Unify and Informix.
368. Can u create foreign key on composite primary key of a table?
No, We can not create foreign key on composite primary key of a table.
369. Write a query unique job for all employees in the deptno is 30 and locate loc the column.
Select distinct a.job,b.loc from emp a,dept b where a.deptno=b.deptno and a.deptno=30;
370. What is use of local and global index? Difference between local and global index?
Local and Global indexes are used in partitioned tables. Local index is partitioned index and
Global index is non-partitioned index.
371. Which global temporary table is default table?
On commit delete row is a default temporary table.

372. What is output of this query?


declare
l1 real;
l2 integer;
l3 float;
l4 pls_integer;
l5 integer;
begin
null;
end;
OUTPUT: NULL
373. What is OLTP and DCE?
OLTP-- On Line Transaction Processing.
DCE--- Distributed Computing Environment.
374. What are different Guis available in the market?
Ms-windows, Power builder, Developer 2000, VB and VC++
375. Number (*,2) will work?
Yes, It will work. It will take default 38 digits for *.
376. You are used stored procedure and package in your project? Which is one is best?
Package.
1
377. What is Self-referential Integrity constraint?
If a foreign key references a parent key of the same table is called self-referential
integrity constraint.
378. What are types of view triggers? And its restrictions.
1. Instead of insert row
2. Instead of update row
3. Instead of delete row.
They are available only at the row level and not at the statement level.
They can be applied only to views and not to table.
379. Can you create instead of trigger for a table?
No, We can not create instead of trigger for a table.
380. How procedures return values?
Procedures return values through parameters.
381. What is difference between pl/sql table and pl/sql record?
1. PL/SQL table is like an array. But PL/SQL record is like structure.

382. Which Database objects used in your project?


Functions, Procedures and Packages.
383. Why do we call oracle is a RDBMS?
Oracle satisfies the 12 Codds rules. So, oracle is called as a Relational Database
Management System(RDBMS)
384. A table is created. After created tables the values are inserted to it, after updated some
columns, after deleted two rows. Now we
want to give rollback. What is result?
Ans:- no rows selected
385. Can you create package specification without package body?
Yes, we can create package specification without package body
386. What objects are used in package?
Procedures, functions, cursor, variable and exception.
387. Function returns more than one values?
Yes, Function returns more than one values.
388. Two tables are there. One is emp and another one is dept. I want all records of emp table as
well as i want record of dept table of
dept no 10 only. Write the query for the above result.
Select a.*,b.* from emp a, dept b where a.deptno=10 and b.deptno=10;
389. Can you include and implement one procedure into package?
Yes, We can include and implement one procedure into package.
390. Can you alter the table synonym?
No, We can not alter the synonym of table.
391. Why are you auditing data modification?
To find who create trigger.
392. How many types of exceptions?
Four types. (a) Pre-defined exceptions (b) Non Predefined exceptions (c) User-defined
exceptions
(Note: Non Predefined exceptions Pragma Exception init)
1.
2.
3.
4.

393. What is difference between stored procedure and package?


Stored procedure is a stand alone object. But package is not a stand alone object.
We can pass parameter in stored procedure but we can not pass parameter in package.
Stored procedure does not have specification section and body section. But package have these
section.
We can do overloading in stored procedure but we can not do overloading in package.

5. We declared cursor in procedure, the performance is slow. We declared cursor in package, the
performance is fast.
Because in procedure every time it will retrieve data from database. But in package
every time it will retrieve data from
SGA.SGA (System Global Area) is a buffer memory. Package has SGA temporary.
6. A cursor declared in a package specification is global and can be accessed by other
procedures or procedures in a package.
A cursor declared in a procedure is local to the procedure that can not be accessed by other
procedures
394. What is system triggers?
System triggers are created while database is created.
395. If you truncate the table, what will happen corresponding view?
Ans: No rows selected.
396. In public procedures are a1, a2, a3. Now they are series a3, a1, a2. Now can u call
procedure a2 into a1?
Yes, We can do.
Create or replace procedure a1
is
begin
---a2();
end a1;
397. What is pseudo record?
New and old qualifiers(correlation identifirers) are available in triggers is called pseudo
record.
398. What is a Cartesian product?
A Cartesian product is the result of an unrestricted join of two or more tables.
399. Two databases a and b. I want the data of b into a.
Using IMP/EXP.
400. What is difference between Rownum and Rowid?
(1) Rownum is a dynamic. But Rowid is a static.
(2) If we delete record from the database Rowid also deleted but Rownum is not deleted.
401. How do you find data type and data length of columns of data type?
Select column_name, data_precision,data_length,data_scale,data_type from cols where
table_name='Table_name';
402. What is syntax of database link?
Create database link <link_name> connect to <user_name> [identified by] password
using <sqlnet_string>;

403. What is output for the following pl/sql program?


Declare
I char(10):='HELLO';
J char(10):='HELLOS';
true char(10);
false char(10);
Begin
If I=J Then
dbms_output.put_line('true');
Else
dbms_output.put_line('false');
End if;
End;
Ans: False
404. Which database link is default?
Private database link is default database link.
405. Which background process is running in DML operation?
Database writer
406. What is single tier, double tier and multi tier?
client only---->single tier. client and server---->double tier. client,server and mediator-->multi-tier.
407. Any other way to allow commit statement in trigger?
Using pragma autonomous_transaction.
408. What is Overloading of procedures?
It is a process of making a procedure to a variety of jobs.

409. After creating a table, we inserted some values into the table and then update some values. I
want commit "insert" only. How?
1. insert statement
2. using savepoint <savepoint name>
3. update statement
4. Rollback to <savepoint name>(refer to step 2)
5. commit.
410. If you use delete command, how is it deletes internally?
Using rollback statement.
411. What is difference between varchar and varcahr2?
Varchar is ANSI product.

Varchar2 is ORACLE product.


412. If no constraint is assigned, what constraint is default assigned in a column of a table?
Null constraint.
413. What is Primary constraint(shortly)?
Not null+unique key+index ==> Primary key constraint.
414. What is data model?
The logical data structure developed during the logical database design process is a data model
or entity model.
415. Which operator to take execute less time: Any or Exists
Exits operator because exits return Boolean value and return any value.
416. What are disadvantages of packages and triggers?
Disadvantages of packages:
1. We can not reference remote packaged variables directly or indirectly.
2. We cannot reference host variable inside package
3. We are not able to grant a procedure in package
4. Unnecessary module loading.
5. Unable to load large packages into memory.
6. Unable to compile large packages.
7. Lack of synonym support.
8. No version control.
Disadvantages of trigger:
1. Writing more number of codes.
2. It is easy to view table relationships, constraints, indexes, stored procedure in database
but triggers are difficult to view.
3. Triggers execute invisible to client-application. They are not visible or can be traced in
debugging code.
4. It is hard to follow their logic as it they can be fired before or after the database
insert/update happens.
5. It is easy to forget about triggers and if there is no.
6. Documentation it will be difficult to figure out for new developers for their existence.
7. Triggers run every time when the database fields are updated and it is overhead on
system. It makes system run slower.
417. What are the return values of functions SQLCODE and SQLERRM?
These are built-in functions. SQLCODE returns current error code. SQLERRM returns
current error message.
418. What are types of trigger?
1. DML triggers.
2. System triggers.

3. Instead of triggers.
419. Is it possible to use commit or rollback in exception part?
Yes, we can use commit or rollback in exception block;
Example:Declare
s varchar2(2);
Begin
update test set a = a+10;
select a into s from test where a=20;
exception
when others then
rollback;
dbms_output.put_line('test'|| s);
End;
420. What is output of this query: select empno,ename from depts union select deptno,dname
from dept
EMPNO ENAME
---------- -------------10 ACCOUNTING
20 RESEARCH
30 SALES
40 OPERATIONS
7369 SMITH
7499 ALLEN
7521 WARD
7566 JONES
7654 MARTIN
7698 BLAKE
7782 CLARK
EMPNO ENAME
---------- -------------7788 SCOTT
7839 KING
7844 TURNER
7876 ADAMS
7900 JAMES
7902 FORD
7934 MILLER

18 rows selected.

421. What is output of this query: Select ename, empno from emp union select
dname,deptno,loc from dept.
It will not be executed because query block has incorrect number of result columns.
422. Can u write procedure without formal parameters?
Yes, We can write procedure without formal parameters.
423. What is output of this query? Select 1 from a (Here a is table)
Ans:
1
----------

1
424. What is output of this query? Select 1 from a where 1=2; (Here a is table)
Ans: no rows selected
425. What is output of this query? Select * from emp,dept where 1=2;
Ans: no rows selected
426. Can u use rowid instead of rownum?
No, We can not use rowid instead of rownum.
427. Can u create synonym for same name as object name?
No, We can not create synonym for same object name.
428. Write query for the following tables use left outer join and right outer join.
T1;
C1
C2
------ ----1
aa
2
bb
3
cc
4
dd
5
ee
6
ff
T2;
C1
C2
------- ----1
a
3
b
5
c
7
d
Ans: Select a.c1,a.c2,b.c1,b.c2 from t1 a, t2 b where a.c1=b.c1(+); ------------Left outer
Join
C1 C2
C1 C2
---------- ---------- ----1 aa
1a
3 cc
3b
5 ee
5c
6 ff
4 dd
2 bb
Ans: Select a.c1,a.c2,b.c1,b.c2 from t1 a, t2 b where a.c1(+)=b.c1 -------------Right
outer join

C1 C2
C1 C2
---------- ---------- ----1 aa
1a
3 cc
3b
5 ee
5c
7d
429. Can u call a procedure in a select statement?
No, We can not call a procedure in a select statement.

430. Write a query to get the sum of salary of each department for each job. By using table emp.
TABLE: EMP
---------------------EMPNO
ENAME
COMM DEPTNO
---------------------------- ----------7499
ALLEN
30
7521
WARD
30
7566
JONES
20
7654
MARTIN
30
7698
BLAKE
30
7782
CLARK
10
7788
SCOTT
20
7839
KING
10
7844
TURNER
30
7876
ADAMS
20
7900
JAMES
30
EMPNO
ENAME
COMM
DEPTNO
---------- ---------------------------- ---7902
FORD
20

JOB
---------

MGR
----------

HIREDATE
--------- ----------

SAL
----------

SALESMAN

7698

20-FEB-81

1600

300

SALESMAN

7698

22-FEB-81

1250

500

MANAGER

7839

02-APR-81

2975

SALESMAN

7698

28-SEP-81

1250

MANAGER

7839

01-MAY-81

2850

MANAGER

7839

09-JUN-81

2450

ANALYST

7566

19-APR-87

3500

17-NOV-81

5000

PRESIDENT
SALESMAN

7698

08-SEP-81

1500

CLERK

7788

23-MAY-87

1100

CLERK

7698

03-DEC-81

950

JOB

MGR

HIREDATE

----------

---------

7566

03-DEC-81

--------ANALYST

SAL
---------3000

1400

7934
10
7369
20

MILLER

CLERK

7782

23-JAN-82

1300

SMITH

CLERK

7902

17-DEC-80

800

SAMPLE OUTPUT
------------------------- JOB SUM_DEPT10
SUM_DEPT20
SUM_DEPT30
SUM_DEPT40
-- --------- ---------- ---------- ------------------------------------------------------------------------------------------------------------ ANALYST
6000
-- CLERK
1300
1900
950
-- MANAGER
2450
2975
2850
-- PRESIDENT 5000
-- SALESMAN
5600
ANSWER:
SELECT job,

sum(decode(deptno,10,sal)) DEPT10,
sum(decode(deptno,20,sal)) DEPT20,
sum(decode(deptno,30,sal)) DEPT30,
sum(decode(deptno,40,sal)) DEPT40
FROM scott.emp GROUP BY job

431. By Using tables, Store_Information and Geography


1.1. Write the a query to find total sales for each store
1.2. Write the a query to get the sales information by region
1.3. Write the a query to find out the sales amount for all of the stores
Table: Store_Information
-----------------------------------store_name Sales Date
--------------------------------------------------Los Angeles 1500 Jan-05-1999
San Diego
250
Jan-07-1999
Los Angeles 300
Jan-08-1999
Boston
700
Jan-08-1999
Table: Geography
-----------------------region_name store_name
---------------------------------------East
Boston
East
New York
West
Los Angeles
West
San Diego
Answer 1.1:

SELECT store_name, SUM(Sales)FROM Store_Information GROUP BY store_name


Result1:
------store_name Sales
---------------------------------Los Angeles 1800
San Diego
250
Boston
700
Answer 1.2:
SELECT A1.region_name REGION, SUM(A2.Sales) SALES FROM Geography A1,
Store_Information A2
WHERE A1.store_name = A2.store_name GROUP BY A1.region_name
Result2:
-------REGION
SALES
---------------------------------East
700
West 2050
Answer 1.3:
SELECT A1.store_name, SUM(A2.Sales) SALES FROM Geography A1,
Store_Information A2
WHERE A1.store_name = A2.store_name (+) GROUP BY A1.store_name
Result3:
-------store_name SALES
---------------------------------Boston
700
New York
Los Angeles 1800
San Diego
250
432. TABLE: Customer
-----------------------Column
Type
------------------------------------------------First_Name
char(50)
Last_Name
char(50)
Address
char(50)
City
char(50)
Country
char(25)
Birth_Date
date
1.1. Create an index on column "Last_Name"

1.2. Create an index on both columns "City and Country"


Answer 1.1:
CREATE INDEX IDX_CUSTOMER_LAST_NAME on CUSTOMER (Last_Name)
Answer 1.2:
CREATE INDEX IDX_CUSTOMER_LOCATION on CUSTOMER (City, Country)

433. Write pl/sql coding for updating emp table using cursor?
declare
Cursor for_cur is select empno,ename,job,mgr,hiredate,sal,comm,deptno from emp where
empno=7369
cust_no for_cur%rowtype;
begin
for cust_no in for_cur loop
update emp_emp set comm=1000 where empno=cust_no.empno;
end loop;
end;
434. Wrtie a stored procedure gets the employee code as parameter, check the value is exists in
the table. Should write exception the
value is there or not.
Create or replace procedure test_proc(emp_no in number)
is
emp_name varchar2(20);
emp_job varchar2(20);
emp_mgr number;
emp_hiredate date;
emp_sal number;
emp_comm number;
emp_deptno number;
begin
select ename,job,mgr,hiredate,sal,comm,deptno into
emp_name,emp_job,emp_mgr,emp_hiredate,
emp_sal,emp_comm,emp_deptno from emp where empno=emp_no;
exception
when no_data_found then
dbms_output.put_line('This record is not available here');
end;
435. Can you pass parameter in cursor?
Yes, We can pass parameter in cursor. (i.e) parameterized cursor.
436. What is DBMS_OUTPUT.PUT_LINE?

DBMS_OUTPUT.PUT_LINE is a package name.


437. How do you delete a column?
Use Alter command.
438. Can u change 1049 to 1000? What query can u use?
Yes, We can change 1049 to 1000.
SQL> select trunc(1049,-3) from dual;
TRUNC(1049,-3)
-------------1000
439. What is output of code?
begin
delete from emps where ename=ename;
end;
Ans: It deleted emps table.
440. How many triggers are used in a single table?
12 triggers.
441. What is difference between pctused and pctfree parameter?
Pct used-- Percentage of used data block.
Pct unused---Percentage of unused data block.
442. How can you store large data?
We can store large data through CLOB.
443. Select * from(select ename from emp)a where---this query execute or it will throw
any error.
Yes, This query will be executed.
Example:- Select * from(select ename from emp)where rownum<=3;
444. Write query to find more than 5 employees from two tables?
SQL> select a.ename,a.empno,b.deptno,b.dname from emp a, dept b where
a.deptno=b.deptno;
ENAME
EMPNO DEPTNO
---------- ---------- ---------- -------------SMITH
7369
20
ALLEN
7499
30
WARD
7521
30
JONES
7566
20
MARTIN
7654
30

DNAME
------------RESEARCH
SALES
SALES
RESEARCH
SALES

BLAKE
CLARK
SCOTT
KING
TURNER
ADAMS
ENAME
---------JAMES
FORD
MILLER

7698
7782
7788
7839
7844
7876

30
10
20
10
30
20

EMPNO DEPTNO
-------------- -------------7900
30
7902
20
7934
10

SALES
ACCOUNTING
RESEARCH
ACCOUNTING
SALES
RESEARCH
DNAME
-------------SALES
RESEARCH
ACCOUNTING

445. What result in count(*) and count(empno) from emp will give same result?
Count(*) count all including null. But count(empno) count except nullable value.
446. The following procedure will be executed or not?
Begin
select ename into vname from emp;
end
Ans: No, It will not be executed. The error is identifier 'VNAME' must be
declared.
447. The following program, after executing exception, control will go to procedure or
not?
declare
emp_name emp.ename%type;
begin
select ename into emp_name from emp where empno=7399;
test(20);
exception
when no_data_found then
dbms_output.put_line('record not found');
end;
Ans: After executing exception control will come out this program.
448. What is no copy?
No copy is a clause or modifier.
449. What is output of this query?
Select * from emp where rownum>5
Ans:- no rows selected
450. How do u create materialized view?
Create materialized view pp for update as select * from emp;
451. How do u start and close the database?

Start the database:- Use startup command


Close the database:- Use shutdown immediate command
452. How do u create user?
Create user ambedkar identified by ambedkar default tablespace users temporary
tablespace temp quota unlimited on users;
453. A table has no data; i want insert data to that table. How can u insert data into that
table through pl/sql?
begin
insert into a1 values(2,'ravi');
end;
454. Now u delete a table sample. After deleting this table a new table sample1 is created and
values are also inserted. Now u want
give rollback. Now sample table have data values or not.
No, Sample table have no data values. (After applying ddl commands previous work
autocomitted)
455. Now u delete a table sample. After deleting this table, insert values for another one table
sample1 (Already created table, but it
has no data). Now u want give rollback. Now sample table have values or not.
Yes, Sample table have data values. But Sample1 table have no data values.
456. How do u populate data, from one table to another table using pl/sql table?
declare
valueinsert table1%rowtype;
type itemtype is table of table1%rowtype index by binary_integer;
item_tab itemtype;
i binary_integer:=0;
begin
for valueinsert in (select * from table1)
loop
i:=i+1;
item_tab(i).id:=valueinsert.id;
item_tab(i).name:=valueinsert.name;
insert into table2 values(item_tab(i).id,item_tab(i).name);
end loop;
end;
SQL> select * from table2;
ID NAME
---------- ---------1 thanga
457. Program:Declare

i_number number not null:=200;


begin
i_number:=100;
dbms_output.put_line(The value of i_number||i_number);
end;
Output of Program:1. 1
2. 100
3. No output
4. Error
5. Can not determined
Ans: 100
458. Create sequence test increment by 1 start with 1 maxvalue 10 minvalue 1 cycle cache 4;
Here what is mean of cache? What is use of cache?
Ans:- Cache means buffer memory. The cache pre-allocates a set of sequence numbers
and retains them in memory.
459. If we have a table as shown below?
Emp_id
Name
Gender
1
muthu
m
2
thanga
m
3
keerthiga
m
4
muthu
m
5
sumathi
f
Which of the above is the primary key?
1. emp_id
2. emp_id and Name
3. can not be determined
4. Gender
Ans: Emp_id
460. What is use of Varchar2 datatype?
1. It stores alphanumeric values as well as numeric values.
2. It saves memory space when compared to char.
461. Draw the ORACLE Architecture.

462. Can a null value is equivalent to a null? Give examples.


No, A null value is not equivalent to a null.
Example(1):declare
i varchar2(10):=null;
j varchar2(10):=null;
begin
if i=j then
dbms_output.put_line('true');
else

Salary
1000
2000
4000
2000
3000

dbms_output.put_line('false');
end if;
end;
Example(2):declare
i number(10):=null;
j number(10):=null;
begin
if i=j then
dbms_output.put_line('true');
else
dbms_output.put_line('false');
end if;
end;
463. What is output of this query?
SQL> select count(*) from emp where rownum=1 group by ename;
COUNT(*)
---------1
464. What is output of this query?
SQL> select instr('ambedkar','e',1,2) from dual;
INSTR('AMBEDKAR','E',1,2)
------------------------0
465. What is output of this query?
SQL> select substr('this is the',6) from dual;
SUBSTR
-----is the
466. What is size of long data type?
2 GB
467. What is size of varchar2 data type?
4000 bytes.
468. What is output of this query?
declare
i number(2);
begin

for i in 1..10 loop


savepoint test;
insert into a values(i);
end loop;
rollback to test;
commit;
end;
Ans:
SQL> select * from a;
A
---------1
2
3
4
5
6
7
8
9
469. What is output of this query?
declare
i number;
begin
i:=i+1;
for i in 1..100 loop
exit when i>100;
end loop;
i:=i+1;
end;
Ans: NULL
470. Which command can be used to show all objects?
User_objects.
Example:- Select * from user_objects
471. How do u display records from more than one table?
Using joins
472. What is difference between on commit delete rows and on commit preserve rows?
After creation of both tables we apply commit statement, on commit delete rows data are deleted.
But on commit preserve rows data are not deleted.
473. What is difference between where clause and having clause?

Having clause is used to find aggregate function.


But where clause is not used to find aggregate function.
474. How do u store data or how do u maintain table?
We can store data of table use data type.
475. What are types of LOB?
1. BLOB: Used to store binary objects( To store photo files)
2. CLOB: Used to store character data( To store book files)
3. NCLOB: Used to store Unicode data.
4. BFILE: Used to store binary objects(To store movie files).
(Note: LOB used to store unstructured data(text, graphic images, video clips and sound
wave forms)
476. Can u create referential constraint for not null column of parent table?
No, We can not create referential constraint for not null column of parent table.
477. What is mean of RAC?
Real Application Cluster.
478. What are physical database structure objects and logical database structure objects?
Physical database structure objects are data file, control file and redo log file. Logical database
structure objects are tables, views, sequences, indexes, procedure, function and packages.
479. How do u run a dynamic sql?
Use execute immediate.
480. Why do not use implicit cursor?
It will slow performance.
481. What is defalut value of boolean?
Ans: null
482. What is difference between snapshot and materialized view?
1. Snapshot is a static. But materialized view is a dynamic.
2. A snapshot used to save query result of a remote database tables. But materialized view
is used to save query result of a
local database tables.
483. How can u import data from text file to database?
We can import data from text file to database using UTL_FILE, sql loader and data
pump.
484. Select empno,ename,sal,comm from emp order by 2; What is mean of order by 2?
It will display order by ename(order by 2 means 2nd column)
485. Select empno,ename,sal,comm from emp order by 3; What is mean of order by 3?

It will display order by sal(order by 3 means 3rd column)


486. Give names for prgamas?
1. Autonomous transaction.
2. Exception init.
487. Can u use out parameter in function?
Yes, We can use out parameter in function.
488. What is package?
Package is a container which contains related objects.
489. Write names for Date function, Numeric function, Character function, Conversion function
and Miscellaneous function.
Date functions:
Add_months,Last_day,Months_between,Round,Next_day,Truncate,Greatest and New_time.
Character functions: Initcap, Lower, Upper, Ltrim, Rtrim, Translate, Replace, Length,
Decode and Concatenation operator.
Numeric functions: Abs, Ceil, Cos, Cosh, Exp, Floor, Power, Mod, Round, Trunc, Sign
and Sqrt.
Conversion functions: To_Char, To_date and To_number.
Miscellaneous functions: Uid,User,NVL and Vsize.
Group functions: Average, Minimum, Maximum, Sum, Count, Group by and Having
clause.
490. Create a package specification and package body called PROD_PACK that contains
ADD_PROD, UPD_PROD,DEL_PROD
procedures and Q_PROD function.
create or replace package prod_pack
is
procedure add_prod(v_prodid in product.prodid%type,v_descrip in product.descrip
%type);
procedure upd_prod(v_prodid in product.prodid%type,v_descrip in product.descrip
%type);
procedure del_prod(v_prodid in product.prodid%type);
function q_prod(v_prodid in product.prodid%type)
return varchar2;
end prod_pack;
create or replace package body prod_pack is
procedure add_prod(v_prodid in product.prodid%type,v_descrip in product.descrip
%type)
is
begin
insert into product(prodid,descrip) values(v_prodid,v_descrip);

end add_prod;
procedure upd_prod(v_prodid in product.prodid%type,v_descrip in product.descrip
%type)
is
begin
update product set descrip=v_descrip where prodid=v_prodid;
if sql%notfound then
raise_application_error(-20202,'no products updated');
end if;
end upd_prod;
procedure del_prod(v_prodid in product.prodid%type)
is
begin
delete from product where prodid=v_prodid;
if sql%notfound then
raise_application_error(-20202,'no products deleted');
end if;
end del_prod;
Function q_prod(v_prodid in product.prodid%type)
return varchar2
is
v_descrip product.descrip%type;
begin
select descrip into v_descrip from product where prodid=v_prodid;
return(v_descrip);
end q_prod;
end prod_pack;
491. Can u order the column values using column alias?
Yes, We can order the column values using column alias.
Example:- Select ename,job,sal+10 annsal from emp order by annsal;
492. Is Rename DML or DCL or DDL or TCL statement?
Rename is a DML statement.
493. What is difference between primary key and foreign key?
1. Primary key does not accept null value but foreign key accept null value.
2. Primary key does not accept duplicate value but foreign key accept duplicate value.
494. What is output of this query?
Select sum(sal) from test. (Here totally two rows. One row sal is 1000 and another row
sal is null)
It will display sum sal. That is it will display 1000 only.

495.

declare
begin
insert into sam values(3,4000);
insert into sam values(4,3000);
end;
Here if any syntax errors in second insert statement, the values are committed or not.
Ans: The values are not committed.

496. Give example for Associate array or pl/sql table.


declare
type list_of_names_t is table of person.first_name%type index by pls_integer;
happyfamily list_of_names_t;
l_row pls_integer;
begin
happyfamily(2020202020):='ELI';
happyfamily(-15070):='Steven';
happyfamily(-90900):='Chris';
happyfamily(88):='Veva';
l_row:=happyfamily.first;
while(l_row is not null)
loop
dbms_output.put_line(happyfamily(l_row));
l_row:=happyfamily.next(l_row);
end loop;
end;
497. When a database set to be a RDBMS?
(a) All mappings(relationship) are supported which is called RDBMS.
(b) All rules are supported which is called a RDBMS.
498. How many percentage of oracle use in web?
97%
499. How many versions are available in oracle?
Oracle--->Oracle--->6.0--->7.0--->7.3--->8.0--->8i--->9i--->10g--->11g
500. What are attributes of opps?
(a) Data Abstraction.
(b) Data Encapsulation.
(c) Data Inheritance.
(d) Data Polymorphism.
501. What are type of functions?
Functions can be classified into two types are system function and user-defined functions.
System functions are classified into two types are single row function and multiple row
function.

Single row functions are classified into char,numeric,date,conversion and general


functions.
502. What is decode?
Decode tells internally if selection logic.
Examples:(a). Select decode(job,'clerk',sal+500,sal) from emp;
Expalanation:if job='clerk'
sal=sal+500
else
sal
(b). Select decode(job,'clerk',sal+500, 'SA', sal+300,'mktg',sal+100, sal) from emp;
503. What are features of oracle 9i?
nullif,nvl2,coalese and case.
504. What are data types available in oracle?
char,varchar,varchar2,date,number(int and dec),long,long row,CLOB,BLOB,NCLOB,
BFILE,NChar,NVarchar2,rowid,Timestamp,Timestamp with T2,
Timestamp with LT2
505. What is difference between tab and cat?
Tab command displays only tables,views and synonyms. But catalog command(cat) displays
complete catalog of all objects in the object.
506. How many columns can we create in a single table?
1024 columns.
507. How many columns can we include in a select statement?
4096 columns.
508. How many tables we can join?
256 tables we can join in a single select statement(we should not give more than 5 tables.
Because it reduces the performance. The processor can not be worked.
509. How many subqueries can we give?
SQL SERVER---> 36 sub queries.
ORACLE-----------> 255 sub queries.
(Note: Single processor does not take more than 8 queries. otherwise it is hang.)
510. What could be the size of processor?
128 mb.
511. How many parameters can we pass in a procedure?

2100 parameters.
512. What is subquery? What are they?
Output of inner query access input of outer query. They are single row subquery, multiple row
subquery, multi-column subquery,scalar sub-query, Inline query and
Correlated sub-query.
513. What is Rownum?
Rownum is a pseudo column. It is a dynamic column created by oracle server or not by
us.
514. What is Rowid?
Rowid is a unique hexadecimal value that gets generated as shown as in the record
inserted into the database.
515. What is difference between commit and rollback?
Committed transactions can not be rollbacked.
Rollbacke transactions can not be committed.
516. Tell about constraints.
Primary key:- Not null+Unique+Index.
Not null key:- It accepts duplicate value and must have value.
Unique key:- It is a distinct value and accpt null value. Example:- Passport number and
emp_id.
(Note: More than one null value accept in oracle only. SQL SERVER accept only one
null value.)
517. What is difference between column level constraint and table level constraint?
In the column level constraints, constraints names are given by system. But table level
constraitns, constraint names are given by user.
518. What are keywords of Alter command?
Drop,Add and Modify.
519. What is use of log?
Log is used to write done dml operations.(This is only possible Delete only)
520. What is view?
View is a logical subset of a table or view is a virtual table.
521. What view contains?
View contains compiled select statement. View does not contain records.
522. What are advantages of view?
1. Firewall/Security.
2. Data Independence.
3. To make complex queries.

523. What is nested view?


Nested view means more view is created.
524. How many views created for a table?
We can create maximum 255 views.
525. What is sequence?
Sequence is sharable object. It is usually used to generate values for primary column.
526. We created a sequence for a table. We inserted more records that table. Now we want give
rollback. Now sequence is rollbacked
or not?
Only records are rollbacked. But sequence not rollbacked.
527. Can we share sequence from one table to another table.
We should not share the sequence for table. But we should share the sequence for user.
528. When will you create index?
Dos
(a) Too large table.
(b) <1/3 rd of the record.
(c) Any column of frequently used where condition.
(d) Primary key and Unique key.
(e) Master table.
Table.

Do not
(a) Too small table.
(b) X
(c) X
(d) Foreign key
(e) Transactional

529. How many indexes can you create for a single table?
We can create maximum 255 indexes for a single table.
530. What are types of PLSQL block?
1. Anonymous Block(Unnamed block)
2. Non anonymous Block(Named block)
(a) Function (b) Procedure
531. When will you write procedure? And When will you write a function?
If you want perform a task write procedure. If you want computer a value write function.
532. What is use of %type?
%Type is a plsql attribute which is used to declare the same data type of back end table
column.
533. What is cursor? What are types of cursor?
Cursor is a private SQL work area. Cursor can be categorized into two types are Implicit
cursor and Explicit cursor.
534. Can you call a procedure into a trigger?
Yes, We can call procedure into a trigger.

535. Can you call a trigger into a procedure?


No, We can not call a trigger into a procedure. We do not need call a trigger into a
procedure.
536. Why do you write procedure?
We write procedure for insert, update and delete records of table.
537. What is database server?
Database server is a program which serves database services to another computer.
538. Who is End user?
End user is a person which use product (client).
539. An Application encounters four types of datas.
1. Simple structured data. Handled by oracle relational model.
2. Complex structured data. Handled by oracle object relational feature (collections,
references and user-defined types)
3. Semi-structured data. Handled by queuing technology (Advanced query)
4. Un-structured data. Handled by LOB
540. Tell about coalesce function.
It will return not null expression if expression evaluate not null, it will return null if
expression evaluate null.
Ex:Select coalesce (address1, address2, address3) result from suppliers.
Coalesce function is like that if then else statement:If address1 is not null then
Result=address1;
Elsif address2 is not null then
Result=address2;
Elsif address3 is not then
Result=address3;
Else
Result=null;
Endif;
Note: The coalesce function will compare each value, one by one.
541. Can you use ddl statements in pl/sql? How?
Yes, We can use ddl statements in pl/sql use dynamic sql.
542. Is foreign key allow duplicate values?
Yes.

543. What is mutating error?


When we will do dml operation for trigger firing table, mutating error will arise.
544. What are two ways to create global temporary table?
way 1:create global temporary table my_temp_table
(column1 number,
column2 number)
on commit delete rows;
way 2:create global temporary table my_temp_table
(column1 number,
column2 number)
on commit preserve rows;
545. What are types of global temporary table?
1. On commit delete rows.
2. On commit preserve rows.
546. What is difference between anonymous block and non anonymous block?
1. Anonymous blocks are unnamed PL/SQL blocks. Non Anonymous blocks are named
PL/SQL blocks. Ex. Subprograms.
2. Anonymous blocks can not be called from other pl/sql blocks. But Non Anonymous
blocks can be called from other pl/sql
block.
3. Anonymous blocks are not stored in database. But Non Anonymous blocks are stored in
database.
4. Anonymous blocks are beginning with keyword is DECLARE or BEGIN. But Non
Anonymous blocks are started with
keyword is CREATE.
547. What are the pre-requisites to modify column and data type of table?
To modify data type of a column the column must be empty. To add a column with NOT NULL
constraint, table
must be empty.
548. Can you write having clause without using group by function?
No, We can not write having function without using group by function.
549. What is locking?
Locking is a mechanism. It prevents data from destructive interaction.
550. What is two-phase commit?
All database servers in a distributed database either commit or rollback.

551. Can you write a cursor into a procedure?


Yes, We can write a cursor into a procedure.
552. In pl/sql block which parts are mandatory?
Begin and End.
553. Tell about RAW and LONG RAW.
RAW is equivalent to VARCHAR2. LONG RAW is equivalent to LONG.
554. As applications can develop to include increasingly richer semantics, they encounter the
need to deal with the
following kinds of data:
(a) Simple structured data - It can be fit into simple tables.
(b) Complex structured data-collections, references, user-defined types.
(c) Semi-structured data-Advanced Queueing, deal with Messages.
(d) Unstructured data -text, graphic images, still video clips, full motion video, and sound
waveforms .
555. Can you declare or define more than one cursor in a procedure?
Yes, We can declare or define more than one cursor in a procedure.
556. Is Rowid physical data structure or logical data structure?
Physical Structure.
557. What is use of PLS_INTEGER?
PLS_INTEGER values require less storage and provide better performance than
NUMBER values.
So we can use PLS_INTEGER. Oracle 9i introduced Binary_Integer. Oracle 10g
introduced PLS_INTEGER.But
both are same.
558. What is use of host variable and bind variable?
Host variable: select * from emp where rownum<&a minus select * from emp where
rownum<&b;
Here &a and &b are host variables.
Posted 18th May 2012 by Sunil K M
0

Add a comment

Oracle DBA Exchange

(I have had all of the disadvantages required for success. - Larry Ellison)

Classic

Flipcard

Magazine

Mosaic

Sidebar

Snapshot

Timeslide

Recent

Date

Label

Author

Cluster Definition
Cluster Definition
Jan 29th
Normalization with Example
Normalization with Example
Jan 29th
Ref Cursor Example
Ref Cursor Example
Jan 28th
RAISE_APPLICATION_ERROR
RAISE_APPLICATION_ERROR
Jan 28th
Wrapping - PL/SQL
Wrapping - PL/SQL
Jan 28th
Procedure - PL/SQL
Procedure - PL/SQL
Jan 26th

Cursor - PL/SQL
Cursor - PL/SQL
Jan 26th
Nested Blocks - Pl/SQL
Nested Blocks - Pl/SQL
Jan 26th
Function - Pl/SQL
Function - Pl/SQL
Jan 25th
EXECUTE IMMEDIATE in PL/SQL
EXECUTE IMMEDIATE in PL/SQL
Jan 25th
DataGuard General Questions
DataGuard General Questions
Nov 21st
Creating a duplicate database with different name using RMAN
Creating a duplicate database with different name using RMAN
Nov 17th
ORA-01031: INSUFFICIENT PRIVILEGES
ORA-01031: INSUFFICIENT PRIVILEGES
Nov 17th
ORA-00845: MEMORY_TARGET not supported on this system
ORA-00845: MEMORY_TARGET not supported on this system
Nov 17th
RMAN INCREMENTAL BACKUP
RMAN INCREMENTAL BACKUP
Nov 16th
changing the hostname Solaris 11
changing the hostname Solaris 11
Nov 16th
Simple Backup and Recovery using RMAN
Simple Backup and Recovery using RMAN
Nov 16th
ORA-00205: error in identifying controlfile
ORA-00205: error in identifying controlfile
Nov 15th
Configuring Network Adapter in Solaris 11
Configuring Network Adapter in Solaris 11
Nov 15th
How to enable SSH Root Login In Solaris 11
How to enable SSH Root Login In Solaris 11
Nov 15th
Manually Cloning an Existing Oracle Database on Linux
Manually Cloning an Existing Oracle Database on Linux
Nov 15th
E-mail Address Validation and Domain Name Extraction

E-mail Address Validation and Domain Name Extraction


May 23rd
SQL join types
SQL join types
May 22nd
1Z0-146 Exam Guide
1Z0-146 Exam Guide
May 22nd 1
The SQLJ loadjava Utility
The SQLJ loadjava Utility
May 21st
SecureFiles: The New LOBs
SecureFiles: The New LOBs
May 21st
Oracle PL/SQL Interview Question and Answers
Oracle PL/SQL Interview Question and Answers
May 18th
Zend Core for Oracle v2
Zend Core for Oracle v2
May 14th
Transportable Tablespaces
Transportable Tablespaces
May 14th
SQL Developer 3.1 Scheduler (DBMS_SCHEDULER) Support
SQL Developer 3.1 Scheduler (DBMS_SCHEDULER) Support
May 14th
SQL Developer 3.1 Data Pump Wizards
SQL Developer 3.1 Data Pump Wizards
May 14th
Schema Owners and Application Users
Schema Owners and Application Users
May 14th
Stored Outlines and Plan Stability
Stored Outlines and Plan Stability
May 14th
Renaming or Moving Oracle Files
Renaming or Moving Oracle Files
May 14th
Recompiling Invalid Schema Objects
Recompiling Invalid Schema Objects
May 14th
Reclaiming Unused Space in Datafiles
Reclaiming Unused Space in Datafiles
May 14th
Partitioning an Existing Table using DBMS_REDEFINITION
Partitioning an Existing Table using DBMS_REDEFINITION

May 13th
Partitioning an Existing Table using EXCHANGE PARTITION
Partitioning an Existing Table using EXCHANGE PARTITION
May 13th
OS Authentication
OS Authentication
May 13th
OS Backup Commands
OS Backup Commands
May 13th
Oracle Shell Scripting
Oracle Shell Scripting
May 13th
Oracle Network Configuration
Oracle Network Configuration
May 13th
Oracle Naming Conventions
Oracle Naming Conventions
May 13th
Measuring Storage Performance For Oracle Systems
Measuring Storage Performance For Oracle Systems
May 13th
Identifying Host Names and IP Addresses
Identifying Host Names and IP Addresses
May 13th
Direct and Asynchronous I/O
Direct and Asynchronous I/O
May 13th
Killing Oracle Sessions
Killing Oracle Sessions
May 12th
Deadlocks
Deadlocks
May 12th
CBO and DBMS_STATS
CBO and DBMS_STATS
May 12th
Basic Security Measures for Oracle
Basic Security Measures for Oracle
May 12th

Loading

Vous aimerez peut-être aussi