Saturday, 26 October 2013

Oracle Interview Questions 04

                                               Placement Papers 




1. What does a COMMIT statement do to a CURSOR

a] Open the Cursor
b] Fetch the Cursor
c] Close the Cursor
d] None of the above
Ans : D
  
2. Which of the following is TRUE

1] Host variables are declared anywhere in the program
2] Host variables are declared in the DECLARE section
a] Only 1 is TRUE
b] Only 2 is TRUE
c] Both 1 & 2are TRUE
d] Both are FALSE
Ans : B
  
3. Which of the following is NOT VALID is PL/SQL

a] Bool boolean;
b] NUM1, NUM2 number;
c] deptname dept.dname%type;
d] date1 date := sysdate
Ans : B
  
4. Declare
fvar number := null; svar number := 5
Begin
goto << fproc>>
if fvar is null then
<< fproc>>
svar := svar + 5
end if;
End;
  
What will be the value of svar after the execution ?
a] Error
b] 10
c] 5
d] None of the above
  
Ans : A

5. Which of the following is not correct about an Exception ?

a] Raised automatically / Explicitly in response to an ORACLE_ERROR
b] An exception will be raised when an error occurs in that block
c] Process terminates after completion of error sequence.
d] A Procedure or Sequence of statements may be processed.
  
Ans : C
  
6. Which of the following is not correct about User_Defined Exceptions ?

a] Must be declared
b] Must be raised explicitly
c] Raised automatically in response to an Oracle error
d] None of the above
  
Ans : C
  
7. A Stored Procedure is a

a] Sequence of SQL or PL/SQL statements to perform specific function
b] Stored in compiled form in the database
c] Can be called from all client environments
d] All of the above
  
Ans : D
  
8. Which of the following statement is false

a] Any procedure can raise an error and return an user message and error number
b] Error number ranging from 20000 to 20999 are reserved for user defined messages
c] Oracle checks Uniqueness of User defined errors
d] Raise_Application_error is used for raising an user defined error.
  
Ans : C
  
9. Is it possible to open a cursor which is in a Package in another procedure ?

a] Yes
b] No
  
Ans : A
  
10. Is it possible to use Transactional control statements in Database Triggers ? 

a] Yes
b] No
  
Ans : B
  
11. Is it possible to Enable or Disable a Database trigger ?

a] Yes
b] No
  
Ans : A
  
12. PL/SQL supports datatype(s)

a] Scalar datatype
b] Composite datatype
c] All of the above
d] None of the above
  
Ans C
  
13. Find the ODD data type out

a] VARCHAR2
b] RECORD
c] BOOLEAN
d] RAW
  
Ans : B
  
14. Which of the following is not correct about the "TABLE" data type ?

a] Can contain any no of columns
b] Simulates a One-dimensional array of unlimited size
c] Column datatype of any Scalar type
d] None of the above
  
Ans : A
  
15. Find the ODD one out of the following

a] OPEN
b] CLOSE
c] INSERT
d] FETCH
  
Ans C
  
16. Which of the following is not correct about Cursor ?

a] Cursor is a named Private SQL area
b] Cursor holds temporary results
c] Cursor is used for retrieving multiple rows
d] SQL uses implicit Cursors to retrieve rows
  
Ans : B
  
18. Which of the following is NOT VALID in PL/SQL ?

a] Select ... into
b] Update
c] Create
d] Delete
  
Ans : C
  
19. What is the Result of the following 'VIK'||NULL||'RAM' ?

a] Error
b] VIK RAM
c] VIKRAM
d] NULL
  
Ans : C
  
20. Declare
a number := 5; b number := null; c number := 10;
Begin
if a > b AND a < c then
a := c * a;
end if;
End;
What will be the value of 'a' after execution ?
a] 50
b] NULL
c] 5
d] None of the above
  
Ans : C

21. Does the Database trigger will fire when the table is TRUNCATED ?

a] Yes
b] No
  
Ans : B
  
22. SUBSTR(SQUARE ANS ALWAYS WORK HARD,14,6) will return

a] ALWAY
b} S ALWA
c] ALWAYS
Ans : C
  
23. REPLACE('JACK AND JUE','J','BL') will return

a] JACK AND BLUE
b] BLACK AND JACK
c] BLACK AND BLUE
d] None of the above
  
Ans : C
  
24. TRANSLATE('333SQD234','0123456789ABCDPQRST','0123456789') will return

a] 333234
b] 333333
c] 234333
d] None of the above
  
Ans : A
  
25.. EMPNO ENAME SAL
A822 RAMASWAMY 3500
A812 NARAYAN 5000
A973 UMESH 2850
A500 BALAJI 5750
  
Use these data for the following Questions
  
Select SAL from EMP E1 where 3 > ( Select count(*) from Emp E2
where E1.SAL > E2.SAL ) will retrieve
a] 3500,5000,2500
b] 5000,2850
c] 2850,5750
d] 5000,5750
  
Ans : A
  
26. Is it possible to modify a Data type of a column when column contains data ?

a] Yes
b] No
  
Ans B
  
27. Which of the following is not correct about a View ?

a] To protect some of the columns of a table from other users
b] Occupies data storage space
c] To hide complexity of a query
d] To hide complexity of a calculations
  
Ans : B
  
28. Which is not part of the Data Definition Language ?

a] CREATE
b] ALTER
c] ALTER SESSION
  
  Ans : C
  
29. The Data Manipulation Language statements are

a] INSERT
b] UPDATE
c] SELECT
d] All of the above
  
Ans : D
  
30. EMPNO ENAME SAL
A822 RAMASWAMY 3500
A812 NARAYAN 5000
A973 UMESH
A500 BALAJI 5750
  
Using the above data Select count(sal) from Emp will retrieve
a] 1
b] 0
c] 3
d] None of the above
  
Ans : C
  
31. If an UNIQUE KEY constraint on DATE column is created, will it accept the rows that are inserted with SYSDATE ?

a] Will
b] Won't
  
Ans : B
  
  
32. What are the different events in Triggers ?

a] Define, Create
b] Drop, Comment
c] Insert, Update, Delete
d] All of the above
  
Ans : C

33. What built-in subprogram is used to manipulate images in image items ?

a] Zoom_out
b] Zoom_in'
c] Image_zoom
d] Zoom_image
  
Ans : C
  
34. Can we pass RECORD GROUP between FORMS ?

a] Yes
b] No
  
Ans : A
  
36. SHOW_ALERT function returns

a] Boolean
b] Number
c] Character
d] None of the above
  
Ans : B
  
37. What SYSTEM VARIABLE is used to refer DATABASE TIME ?

a] $$dbtime$$
b] $$time$$
c] $$datetime$$
d] None of the above
  
Ans : A
  
38. :SYSTEM.EFFECTIVE.DATE varaible is

a] Read only
b] Read & Write
c] Write only
d] None of the above
  
Ans : C
  
39.. How can you CALL Reports from Forms4.0 ?

a] Run_Report built_in
b] Call_Report built_in
c] Run_Product built_in
d] Call_Product built_in
  
Ans : C
  
85. When do you get a .PLL extension ?
a] Save Library file
b] Generate Library file
c] Run Library file
d] None of the above
  
Ans : A
  
40. What is built_in Subprogram ?

a] Stored procedure & Function
b] Collection of Subprogram
c] Collection of Packages
d] None of the above
  
Ans : D
  
41. GET_BLOCK property is a

a] Restricted procedure
b] Unrestricted procedure
c] Library function
d] None of the above

Wednesday, 23 October 2013

Oracle Interview Questions 03


                                                 Question For Experienced People




1)How do you identify  the problematic sql statements?

2)What is the process followed to tune sql statements?

3)What is explain plan?

4)What do you look for in explain plan?

5)I have 40 lines of code in plsql block, I got exception at 9 line,but still I want to continue from 10th line.How to achieve this?

6)How do you move your code from development to production ?

7)What tools do you use to move your code from development to production?



Ans

1) AWR (Identifying High-Load SQL Statements)

2) There is might be more process. Beginning with validation /cretion index ending , gather_stats, rewriting query, etcc. ending changing database parameters

3) Plan how ORACLE will execute the query

4)?
5) catching exception block.

6) ?

7) SVN, batch file, copy/paste, etc. look "6"



                             [NB:-Few questions base on your real time environment]

Tuesday, 22 October 2013

Oracle Interview Questions 02

Oracle Interview Questions and Answers : SQL
------------------------------------------------------------------------------------------
1. To see current user name
Sql> show user;

2. Change SQL prompt name
SQL> set sqlprompt “Manimara > “
Manimara >
Manimara >

3. Switch to DOS prompt
SQL> host

4. How do I eliminate the duplicate rows ?
SQL> delete from table_name where rowid not in (select max(rowid) from table group by
duplicate_values_field_name);
or
SQL> delete duplicate_values_field_name dv from table_name ta where rowid <(select min(rowid) from
table_name tb where ta.dv=tb.dv);
Example.
Table Emp
Empno Ename
101 Scott
102 Jiyo
103 Millor
104 Jiyo
105 Smith
delete ename from emp a where rowid < ( select min(rowid) from emp b where a.ename = b.ename);
The output like,
Empno Ename
101 Scott
102 Millor
103 Jiyo
104 Smith

5. How do I display row number with records?
To achive this use rownum pseudocolumn with query, like SQL> SQL> select rownum, ename from emp;
Output:
1 Scott
2 Millor
3 Jiyo
4 Smith
6. Display the records between two range
select rownum, empno, ename from emp where rowid in
(select rowid from emp where rownum <=&upto
minus
select rowid from emp where rownum<&Start);
Enter value for upto: 10
Enter value for Start: 7
ROWNUM EMPNO ENAME
--------- --------- ----------
1 7782 CLARK
2 7788 SCOTT
3 7839 KING
4 7844 TURNER

7. I know the nvl function only allows the same data type(ie. number or char or date
Nvl(comm, 0)), if commission is null then the text “Not Applicable” want to display, instead of
blank space. How do I write the query?
SQL> select nvl(to_char(comm.),'NA') from emp;
Output :
NVL(TO_CHAR(COMM),'NA')
-----------------------
NA
300
500
NA
1400
NA
NA

8. Oracle cursor : Implicit & Explicit cursors
Oracle uses work areas called private SQL areas to create SQL statements.
PL/SQL construct to identify each and every work are used, is called as Cursor.
For SQL queries returning a single row, PL/SQL declares all implicit cursors.
For queries that returning more than one row, the cursor needs to be explicitly declared.

9. Explicit Cursor attributes
There are four cursor attributes used in Oracle
cursor_name%Found, cursor_name%NOTFOUND, cursor_name%ROWCOUNT, cursor_name%ISOPEN

10. Implicit Cursor attributes
Same as explicit cursor but prefixed by the word SQL
SQL%Found, SQL%NOTFOUND, SQL%ROWCOUNT, SQL%ISOPEN
Tips : 1. Here SQL%ISOPEN is false, because oracle automatically closed the implicit cursor after
executing SQL statements.
: 2. All are Boolean attributes.

11. Find out nth highest salary from emp table
SELECT DISTINCT (a.sal) FROM EMP A WHERE &N = (SELECT COUNT (DISTINCT (b.sal)) FROM EMP B
WHERE a.sal<=b.sal);
Enter value for n: 2
SAL
---------
3700

12. To view installed Oracle version information
SQL> select banner from v$version;

13. Display the number value in Words
SQL> select sal, (to_char(to_date(sal,'j'), 'jsp'))
from emp;
the output like,
SAL (TO_CHAR(TO_DATE(SAL,'J'),'JSP'))
--------- -----------------------------------------------------
800 eight hundred
1600 one thousand six hundred
1250 one thousand two hundred fifty
If you want to add some text like,
Rs. Three Thousand only.
SQL> select sal "Salary ",
(' Rs. '|| (to_char(to_date(sal,'j'), 'Jsp'))|| ' only.'))
"Sal in Words" from emp
/
Salary Sal in Words
------- ------------------------------------------------------
800 Rs. Eight Hundred only.
1600 Rs. One Thousand Six Hundred only.
1250 Rs. One Thousand Two Hundred Fifty only.
14. Display Odd/ Even number of records
Odd number of records:
select * from emp where (rowid,1) in (select rowid, mod(rownum,2) from emp);
1
3
5
Even number of records:
select * from emp where (rowid,0) in (select rowid, mod(rownum,2) from emp)
2
4
6
15. Which date function returns number value?

months_between
16. Any three PL/SQL Exceptions?

Too_many_rows, No_Data_Found, Value_Error, Zero_Error, Others

17. What are PL/SQL Cursor Exceptions?
Cursor_Already_Open, Invalid_Cursor

18. Other way to replace query result null value with a text
SQL> Set NULL ‘N/A’
to reset SQL> Set NULL ‘’

19. What are the more common pseudo-columns?
SYSDATE, USER , UID, CURVAL, NEXTVAL, ROWID, ROWNUM

20. What is the output of SIGN function?
1 for positive value,
0 for Zero,
-1 for Negative value.

21. What is the maximum number of triggers, can apply to a single table?

12 triggers.

Saturday, 1 June 2013

Oracle Interview Questions 01

                                       ORACLE FAQ’s
                             --------------------
General Questions
§                     Tell us about yourself/ your background.?
§                     What are the three major characteristics that you bring to the job market?
§                     What motivates you to do a good job?
§                     What two or three things are most important to you at work?
§                     What qualities do you think are essential to be successful in this kind of work?
§                     What courses did you attend? What job certifications do you hold?
§                     What subjects/courses did you excel in? Why?
§                     What subjects/courses gave you trouble? Why?
§                     How does your previous work experience prepare you for this position?
§                     How do you define 'success'?
§                     What has been your most significant accomplishment to date?
§                     Describe a challenge you encountered and how you dealt with it.
§                     Describe a failure and how you dealt with it.
§                     Describe the 'ideal' job... the 'ideal' supervisor.
§                     What leadership roles have you held?
§                     What prejudices do you hold?
§                     What do you like to do in your spare time?
§                     What are your career goals (a) 3 years from now; (b) 10 years from now?
§                     How does this position match your career goals?
§                     What have you done in the past year to improve yourself?
§                     In what areas do you feel you need further education and training to be successful?
§                     What do you know about our company?
§                     Why do you want to work for this company. Why should we hire you?
§                     Where do you see yourself fitting in to this organization ...initially? ...in 5 years?
§                     Why are you looking for a new job?
§                     How do you feel about re-locating?
§                     Are you willing to travel?
§                     What are your salary requirements?
§                     When would you be available to start if you were selected?