You are on page 1of 5

Please verify the answers from your side and learn, the given answers might be

wrong
And for some questions I don't know the answers.

1)SELECT trunc(�30-OCT-2013�,�YEAR�) FROM DUAL;


� 42184
� 42640
� Syntax error
� 42175

2) Pragma that will call itself independently and can separate main user query from
it is �
� Pragma autonomous transaction
� Pragma exception init
� None of options
� Pragma restrict references

ans: Pragma autonomous transaction

3)How do you display '01-01-2001' , from 01-jan-01


� to_char('01-jan-01')
�trunc(to_char('01-jan-01')
�round(to_char('01-jan-01')
�to_char(trunc('01-jan-01')
(not sure of the options, but something like this came)

4)how to display "ello world" from Hello World


ans:lower(trim('H' from "Hello World"))

5)CREATE OR REPLACE FUNCTION CALC_PLAYER_AVG


(V_ID in PLAYER_BAT_STAT.PLAYER_ID%TYPE)
RETURN NUMBER IS V_AVG NUMBER;
BEGIN
SELECT HITS / AT_BATS INTO V_AVG
FROM PLAYER_BAT_STAT
WHERE PLAYER_ID = V_ID;
RETURN (V_AVG);
END;
Which statement will successfully invoke this function in SQL *Plus?
� SELECT CALC_PLAYER_AVG(PLAYER_ID) FROM PLAYER_BAT_STAT;
� EXECUTE CALC_PLAYER_AVG(31);
� CALC_PLAYER('RUTH');
� CALC_PLAYER_AVG(31);
� START CALC_PLAYER_AVG(31)

ans: SELECT CALC_PLAYER_AVG(PLAYER_ID) FROM PLAYER_BAT_STAT; and


CALC_PLAYER_AVG(31);

6)Which operation is used for joining two tables which have same number of columns:
� Union

7)Select 1 from dual


Union
Select 1 from dual
Union
Select 3 from dual;
Ans:
1
3 (because union, intersection and minus operations will display only distinct
records)

8) how to you display the employee and department table, even if there are no
matching departments (unable to frame question exactly )

ans: full outer join/outer join.

9)Which of the following are used to release all database locks? (check box)
� Commit
� Rollback
� Save
� Savepoint

ans: Rollback and Commit

10) DECLARE
p_emp_no NUMBER :=1;
BEGIN
FOR I IN 1....10 LOOP
update employee
set ename='John'
WHERE emp_no=p_emp_no;
END LOOP;
END;

How many execution plans generated for this statement.


� 1
� 10
� 5
� 1
ans: 1

11) When is the wildcard in a WHERE clause useful?


ans: An exact match is not possible in a SELECT statement

12)what is oracle views:


View is a virtual table that can be accessed via SQL commands

13) Which of the below datatypes are supported by Oracle?


I. Scalar datatype
II. Composite datatype
III. Large Object (LOB) datatype

ans: all

14)which oracle access method make query processing easier.


� Creating unique index
� Primary key access
� Access with rowid
� Full table scan
ans: access with rowid

15) which of the following are true


a. group by clause is executed before having clause.
b. order by caluse is executed after having clause.
(don't remember all options)
(order of execution of statements: from, where,group by, having ,select,order by)
16) The PRODUCT table contains these columns:
PRODUCT_ID NUMBER(9)
PRODUCT_NAME VARCHAR(25)
COST NUMBER(5,2)
LIST_PRICE NUMBER(5,2)
SUPPLIER_ID NUMBER(9)

Display product names,cost, supplier ids and avgerage price.

(for this question they might change the ques ,keeping the ans unchanged, read the
ques carefully and ans accordingly)

ans: SELECT product_name,cost,supplier_id ,avg(list_price) from product group by


product_name,cost,supplier_id;

17 ) One question related to the above (16th question) type


Similarly, to display some columns along with that need to find the profit
Profit can be calculated as (retail amount � (retail amount *25%)) as profit

18) Which of the following is not correct about User_Defied Exceptions?


a. Rasied automatically in response to an Oracle Error
b. Must be declared
c.Must be handled by referencing the Exception name in the Exception Handler
d. Must be raised explicitly

19) (one more questions related to exceptions came)

20) Which of the statements about subqueries are true?


a.A single row subquery can retrieve only one row but many cloumns
b. subqueries can be correlated and non correlated
c. Amultiple row subquery can be compared using the ">" operator
d.A multiple row subquery can use the "=" operator.

21)The user needs to perform certain data manipluation operations through a view
called EMP_DEPT_VU, which he/she previously created. The user wants to look at the
definition of the view. How he/she obtain the definition of the view using a query?
a. Query the USER_VIEWS data dictionary to search for the EMP_DEPT_VU view.
b. Query the USER_OBJECTS data data dictionary view to search for the EMP_DEPT_VU
c. Query the USER_SOURCE data dictionary view to search for the EMP_DEPT_VU view
d. Use the DEFINE VIEW command on the EMP_DEPT_VU view.

22) STD_ID NUMBER(4)


COURSE_ID VARCHAR(10)
START_DATE DATE
END_DATE DATE

Which two aggregate functions are valid on the START_DATE cloumn?

a. COUNT(start_date)
b.AVG(start_date,end_date)
c.SUM(start_date)
d.MIN(start_date)

ans: count,min

23) What is another name for simple join or inner join?


ans: Equijoin
24) SELECT to_char('05-09-2015',MONTH) from dual;
ans: September

25) All users currently have INSERT privileges on the LIBRARY table.You want only
your users to insert into this table using the ADD_BOOK procedure.Which two actions
muct you take?

a. GRANT EXECUTE ON ADD_BOOK TO PUBLIC


b. REVOKE INSERT ON LIBRARY FROM PUBLIC

26) trunc(56.892)
ans:56

27)Which of the following is an aggregate function?


ans:MIN

28) which function is used to add 4 zeros to the left of a cloumn


ans: LPAD

29)select emp.ename,dept.dname from emp JOIN dept on emp.dno=dept.dno;


1.Natural Join 2.Inner Join 3.Equi Join 4.Outer Join
Ans: Equi Join
(similar question came)

30)10. IF AN INTERSECT STATEMENT IS issued between two tables one table


customer with 4 rows and another table customer_2 with 10 rows. But none of the
customer_id are matching between both tables. Then how many rows are returned.
� 0
� 40
� 10
� 4
ans:0

31) You cannot add a subquery to a SELECT clause as a cloumn expression in the
SELECT list.
ans: False

32)With SQL,how do you select all the records from a table named "Persons" where
the value of the cloumn " FirstName" starts with "a"?

ans: Select * from Persons where FirstName LIKE 'a%';

33) Consider a "DEPARTMENT" table with five records.How many rows will be updated
by the below query?

UPDATE department SET department_id=5

ans: All Rows in the table


34) A view stores the data physically in database

ans: False

35) SELECT CUSTOMER.CUSTOMER_ID,ORDER.CUSTOMER_ID,NAME,ORDER_ID FROM CUSTOMER,ORDER


(similar ques came)

ans: Cartesian join


36)If we trim S from SSNNSSS, then output:
� NN
� NNSSS
� BLANK OUTPUT
� NONE

ans: NN
37)Under which two circumstances do you design database triggers? (Choose two)
(same ques different option came)
A. To duplicate the functionality of other triggers.
B. To replicate built-in constraints in the Oracle server such as primary key
and foreign key.
C. To guarantee that when a specific operation is performed, related actions are
performed.
D. For centralized, global operations that should be fired for the triggering
statement, regardless of which user or application issues the statement.
ans: c and d

38)Update departments set department_id=(select department_id from departments);


(same ques different options came)
This statement if department_id is returned multiple means what it will do?
� Throw syntax error
� No rows are updated
� It will update with department_id value
� None
ans: Throws syntax error

2-3 :ques related to types of joins


2 :questions find the error/ what is wrong in the given snippet
10 :ques on packages,triggers
2-3 :ques on subqueries
many :ques on trunc,round,date,aggregate function
1 :ques related to primary key, not null ,foreign key constrains

You might also like