|
Sql Interview Questions and Answers
Examine this code
71. BEGIN
72. theater_pck.v_total_seats_sold_overall :=
theater_pck.get_total_for_year;
73. END;
For this code to be successful, what must be true?
1. Both the V_TOTAL_SEATS_SOLD_OVERALL variable and the
GET_TOTAL_FOR_YEAR function must exist only in the body of the
THEATER_PCK package.
2. Only the GET_TOTAL_FOR_YEAR variable must exist in the specification
of the THEATER_PCK package.
3. Only the V_TOTAL_SEATS_SOLD_OVERALL variable must exist in the
specification of the THEATER_PCK package.
4. Both the V_TOTAL_SEATS_SOLD_OVERALL variable and the
GET_TOTAL_FOR_YEAR function must exist in the specification of the
THEATER_PCK package.
A stored function must return a value based on conditions that are
determined at runtime. Therefore, the SELECT statement cannot be
hard-coded and must be created dynamically when the function is
executed. Which Oracle supplied package will enable this feature?
1. DBMS_DDL
2. DBMS_DML
3. DBMS_SYN
4. DBMS_SQL
A stored function must return a value based on conditions that are
determined at runtime. Therefore, the SELECT statement cannot be
hard-coded and must be created dynamically when the function is
executed. Which Oracle supplied package will enable this feature?
1. DBMS_DDL
2. DBMS_DML
3. DBMS_SYN
4. DBMS_SQL
How to implement ISNUMERIC function in SQL *Plus ?
Method 1:
Select length (translate (trim (column_name),' +-.0123456789',' ')) from
dual ;
Will give you a zero if it is a number or greater than zero if not
numeric (actually gives the count of non numeric characters)
Method 2:
select instr(translate('wwww',
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'),'X')
FROM dual;
It returns 0 if it is a number, 1 if it is not.
How to Select last N records from a Table?
select * from (select rownum a, CLASS_CODE,CLASS_DESC from clm)
where a > ( select (max(rownum)-10) from clm)
Here N = 10
The following query has a Problem of performance in the execution of the
following query where the table ter.ter_master have 22231 records. So
the results are obtained after hours.
Cursor rem_master(brepno VARCHAR2) IS
select a.* from ter.ter_master a
where NOT a.repno in (select repno from ermast) and
(brepno = 'ALL' or a.repno > brepno)
Order by a.repno
What are steps required tuning this query to improve its performance?
-Have an index on TER_MASTER.REPNO and one on ERMAST.REPNO
-Be sure to get familiar with EXPLAIN PLAN. This can help you determine
the execution path that Oracle takes. If you are using Cost Based
Optimizer mode, then be sure that your statistics on TER_MASTER are
up-to-date. -Also, you can change your SQL to:
SELECT a.*
FROM ter.ter_master a
WHERE NOT EXISTS (SELECT b.repno FROM ermast b
WHERE a.repno=b.repno) AND
(a.brepno = 'ALL' or a.repno > a.brepno)
ORDER BY a.repno;
What is the difference between Truncate and Delete interms of
Referential Integrity?
DELETE removes one or more records in a table, checking referential
Constraints (to see if there are dependent child records) and firing any
DELETE triggers. In the order you are deleting (child first then parent)
There will be no problems.
TRUNCATE removes ALL records in a table. It does not execute any
triggers. Also, it only checks for the existence (and status) of another
foreign key Pointing to the table. If one exists and is enabled, then
you will get The following error. This is true even if you do the child
tables first.
ORA-02266: unique/primary keys in table referenced by enabled foreign
keys
You should disable the foreign key constraints in the child tables
before issuing the TRUNCATE command, then re-enable them afterwards.
Page Numbers
:
1
2
3
4
5
6
7
8
9
10
11
Have a Question ?
post your questions here. It
will be answered as soon as possible.
Check
HTML Interview
Questions for more HTML Interview Questions with Answers
Check
Job Interview Questions
for more Interview Questions with Answers
|