SQL Interview Question III

6
7/24/2019 SQL Interview Question III http://slidepdf.com/reader/full/sql-interview-question-iii 1/6 SQL and PL/SQL Interview questions-III SQL and PL/SQL Interview questions-III 85. Under which circumstance must you recompile the package body after recompiling the package specification? 1. Altering the argument list of one of the package constructs 2. Any change made to one of the package constructs 3. Any SQL statement change made to one of the package constructs 4. Removing a local variale from the !"#LAR" section of one of the package constructs 86. Procedure and Functions are explicitly executed. his is different from a database trigger. !hen is a database trigger executed? 1. $hen the transaction is committed 2. !uring the data manipulation statement 3. $hen an %racle supplied package references the trigger 4. !uring a data manipulation statement and &hen the transaction is committed 8". !hich #racle supplied package can you use to output $alues and messages from database triggers% stored procedures and functions within &'()Plus? 1. !'(S)!*S+LA, 2. !'(S)%-+- 3. !'(S)L*S 4. !'(S)!"S#R*'" 88. !hat occurs if a procedure or function terminates with failure without being handled? 1. Any !(L statements issued y the construct are still pending and can e committed or rolled ack. 2. Any !(L statements issued y the construct are committed 3. -nless a /%% statement is used to continue processing &ithin the '"/*0 section the construct terminates. 4. he construct rolls ack any !(L statements issued and returns the unhandled eception to the calling environment. 8*. +xamine this code 1. '"/*0 2. theater)pck.v)total)seats)sold)overall 5 theater)pck.get)total)for)year6 3. "0!6 7or this code to e successful &hat must e true8 1. 'oth the 9)%AL)S"AS)S%L!)%9"RALL variale and the /")%AL)7%R),"AR function must eist only in the ody of the :"A"R)+#; package. 2. %nly the /")%AL)7%R),"AR variale must eist in the specification of the :"A"R)+#; package. 3. %nly the 9)%AL)S"AS)S%L!)%9"RALL variale must eist in the specification of the :"A"R)+#; package. 4. 'oth the 9)%AL)S"AS)S%L!)%9"RALL variale and the /")%AL)7%R),"AR function must eist in the specification of the :"A"R)+#; package. *, - stored function must return a $alue based on conditions that are determined at runtime. herefore% the &+(+ statement cannot be hard/coded and must be created dynamically when the function is executed. !hich #racle supplied package will enable this feature?

Transcript of SQL Interview Question III

Page 1: SQL Interview Question III

7/24/2019 SQL Interview Question III

http://slidepdf.com/reader/full/sql-interview-question-iii 1/6

SQL and PL/SQL Interview questions-III 

SQL and PL/SQL Interview questions-III

85. Under which circumstance must you recompile the package body afterrecompiling the package specification?

1. Altering the argument list of one of the package constructs2. Any change made to one of the package constructs

3. Any SQL statement change made to one of the package constructs4. Removing a local variale from the !"#LAR" section of one of the package constructs

86. Procedure and Functions are explicitly executed. his is different from adatabase trigger. !hen is a database trigger executed?

1. $hen the transaction is committed2. !uring the data manipulation statement

3. $hen an %racle supplied package references the trigger4. !uring a data manipulation statement and &hen the transaction is committed

8". !hich #racle supplied package can you use to output $alues and messagesfrom database triggers% stored procedures and functions within &'()Plus?

1. !'(S)!*S+LA, 2. !'(S)%-+- 3. !'(S)L*S 4. !'(S)!"S#R*'"

88. !hat occurs if a procedure or function terminates with failure without being

handled?1. Any !(L statements issued y the construct are still pending and can e committed or

rolled ack.2. Any !(L statements issued y the construct are committed

3. -nless a /%% statement is used to continue processing &ithin the '"/*0 section theconstruct terminates.

4. he construct rolls ack any !(L statements issued and returns the unhandled eceptionto the calling environment.

8*. +xamine this code1. '"/*0

2. theater)pck.v)total)seats)sold)overall 5 theater)pck.get)total)for)year63. "0!6

7or this code to e successful &hat must e true8

1. 'oth the 9)%AL)S"AS)S%L!)%9"RALL variale and the /")%AL)7%R),"ARfunction must eist only in the ody of the :"A"R)+#; package.

2. %nly the /")%AL)7%R),"AR variale must eist in the specification of the:"A"R)+#; package.

3. %nly the 9)%AL)S"AS)S%L!)%9"RALL variale must eist in the specification of the:"A"R)+#; package.4. 'oth the 9)%AL)S"AS)S%L!)%9"RALL variale and the /")%AL)7%R),"AR

function must eist in the specification of the :"A"R)+#; package.

*, - stored function must return a $alue based on conditions that are determinedat runtime. herefore% the &+(+ statement cannot be hard/coded and must be

created dynamically when the function is executed. !hich #racle suppliedpackage will enable this feature?

Page 2: SQL Interview Question III

7/24/2019 SQL Interview Question III

http://slidepdf.com/reader/full/sql-interview-question-iii 2/6

1. !'(S)!!L2. !'(S)!(L

3. !'(S)S,04. !'(S)SQL

*, - stored function must return a $alue based on conditions that are determined

at runtime. herefore% the &+(+ statement cannot be hard/coded and must becreated dynamically when the function is executed. !hich #racle suppliedpackage will enable this feature?

1. !'(S)!!L2. !'(S)!(L

3. !'(S)S,04. !'(S)SQL

*0 1ow to implement 2&3U4+2 function in &'( )Plus ?(ethod 1

Select length <translate <trim <column)name=> [email protected]>> >== from dual 6

$ill give you a Fero if it is a numer or greater than Fero if not numeric <actually gives the

count of non numeric characters=

(ethod 2

select instr<translate<>&&&&>

>acdefghiGklmnopHrstuv&yFA'#!"7/:*I;L(0%+QRS-9$J,K>>JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ>=>J>=

7R%( dual6

*t returns if it is a numer 1 if it is not.

* 1ow to &elect last 3 records from a able?

select from <select ro&num a #LASS)#%!"#LASS)!"S# from clm=&here a M < select <ma<ro&num=@1= from clm=

:ere 0 5 1

he follo&ing Huery has a +rolem of performance in the eecution of the follo&ing Huery&here the tale ter.ter)master have 22231 records. So the results are otained after hours.

#ursor rem)master<repno 9AR#:AR2= *S

select a. from ter.ter)master a&here 0% a.repno in <select repno from ermast= and

<repno 5 >ALL> or a.repno M repno=%rder y a.repno

$hat are steps reHuired tuning this Huery to improve its performance8

@:ave an inde on "R)(AS"R.R"+0% and one on "R(AS.R"+0%

@'e sure to get familiar &ith "J+LA*0 +LA0. his can help you determine the eecution path

that %racle takes. *f you are using #ost 'ased %ptimiFer mode then e sure that yourstatistics on "R)(AS"R are up@to@date. @Also you can change your SQL to

Page 3: SQL Interview Question III

7/24/2019 SQL Interview Question III

http://slidepdf.com/reader/full/sql-interview-question-iii 3/6

S"L"# a.7R%( ter.ter)master a

$:"R" 0% "J*SS <S"L"# .repno 7R%( ermast $:"R" a.repno5.repno= A0!

<a.repno 5 >ALL> or a.repno M a.repno=%R!"R ', a.repno6

*7 !hat is the difference between runcate and elete interms of eferential2ntegrity?

!"L"" removes one or more records in a tale checking referential #onstraints <to see ifthere are dependent child records= and firing any !"L"" triggers. *n the order you are

deleting <child first then parent= here &ill e no prolems.R-0#A" removes ALL records in a tale. *t does not eecute any triggers. Also it only

checks for the eistence <and status= of another foreign key +ointing to the tale. *f oneeists and is enaled then you &ill get he follo&ing error. his is true even if you do the

child tales first.

%RA@22CC uniHueNprimary keys in tale referenced y enaled foreign keys,ou should disale the foreign key constraints in the child tales efore issuing the

R-0#A" command then re@enale them after&ards.

(2+39&+:+

*;. !hat does preempti$e in preempti$e multitasking mean ?

+reemptive refers to the fact that each task is alloted fied time slots and at the end of thattime slot the net task is started.

*5. !hat does the #(P stands for ?%L+ stands for %n Line ransaction +rocessing

*6. !hat is the most important re<uirement for #(P ?%L+ reHuires real time response.

*". 2n a client ser$er en$ironment% what would be the ma=or work that the clientdeals with ?

he client deals &ith the user interface part of the system.

*8. !hy is the most of the processing done at the se$er ?o reduce the net&ork traffic and for application sharing and implementing usiness rules.

**. !hat does teh term upsi>ing refer to ?

Applications that have outgro&n their environment are re@engineered to run in a largerenvironment. his is upsiFing.

0,,. !hat does one do when one is rightsi>ing ?

$ith rightsiFing one &ould move applications to the most appropriate server platforms.

0,0. !hat does the term downsi>ing refer to ?A host ased application is re@engineered to run in smaller or LA0 ased environment.

0,. !hat is e$ent trigger ?An event trigger a segment of code &hich is associated &ith each event and is fired &hen

the event occurs.

Page 4: SQL Interview Question III

7/24/2019 SQL Interview Question III

http://slidepdf.com/reader/full/sql-interview-question-iii 4/6

0,7. !hy do stored procedures reduce network traffic ?$hen a stored procedure is called only the procedure call is sent to the server and not the

statements that the procedure contains.0,;. !hat are the types of processes that a ser$er runs ?

7oreground process and 'ackground process.

0,5. !hat is a e$ent handler ?

An event handler is a routine that is &ritten to respond to a particular event.

0,6. !hat is an integrity constraint ?

An integrity constraint allo&s the definition of certain restrictions at the tale level on thedata that is entered into a tale.

0,". !hat are the $arious uses of database triggers ?!ataase triggers can e used to enforce usiness rules to maintain derived values and

perform value@ased auditing.

0,8. !hat is a transaction ?A transaction is a set of operations that egin &hen the first !(L is issued and end &hen acommit or rollack is issued. '"/*0 #%((*NR%LL'A#; are the oundries of a transaction.

0,*. !hy are the integrity constraints preferred to database triggers ?'ecause it is easier to define an integrity constraint than a dataase trigger.

00,. !hy is it better to use an integrity constraint to $alidate data in a table thanto use a stored procedure ?

'ecause an integrity constraint is automatically checked &hile data is inserted into a tale. Astored has to e specifically invoked.

000. !hat are the three components of a client ser$er model ?A #lient

A Server andA 0et&orkN#ommunication soft&are.

00. !hat are the ad$antages of client9ser$er model ?

7leiility of the system scalaility cost saving centralised control and implementation ofusiness rules increase of developers productivity portaility improved net&ork and

resource utiliFation.

007. !hat are the disad$antages of the client9ser$er model ?:eterogeneity of the system results in reduced reliality. (ay not e suitale for all

applications. (anaging and tuning net&orks ecomes difficult.

00;. !hat are the different topologies a$ailable for network ?

Star'us

Ring.

005. !hat is the first work of lient process ?

A client process at first estalishes connection &ith the Server.

Page 5: SQL Interview Question III

7/24/2019 SQL Interview Question III

http://slidepdf.com/reader/full/sql-interview-question-iii 5/6

005. !hat are the responsibilities of a &er$er ?1. (anage resources optimally across multiple clients.

2. #ontrolling dataase access and security.3. +rotecting the datase and recovering it from crashes.

4. "nforcing integrity rules gloally.

006. 2n a lient9&er$er context% what does -P2 -pplication Programming2nterface@ refer to ?An A+* in a #lientNServer contet is a specification of a set of functions for communication

et&een the client and the server.

00". Ai$e some examples of standard -P2??s ?

%pen !ataase #onnectivity <%!'#=*ntegrated !ataase Application +rogramming *nterface <*!A+*=

J%penSQLN#L*

008. !hat is the main ad$antage of de$eloping an application using an -P2 ?

he application can e connected to any ack end server that is supported y the A+*.

00*. !hat is the main disad$antage of de$eloping an application using an -P2 ?he application cannot use any special features of the ackend server.

0,. !hy is an e$ent dri$en program referred to a passi$e program ?'ecause an event driven program is al&ays &aiting for something to happen efore

processing.

0,. !hat are the four types of e$ents ?

1. System "vents.2. #ontrol "vents

3. -ser "vents4. %ther "vents.

00. !hat is the difference between file ser$er and a database ser$er ?A file server Gust transfers all the data reHuested y all its client and the client processes the

data &hile a dataase server runs the Huery and sends only the Huery output.

0. !hat is inheritance ?

*nheritance is a method y &hich properties and methods of an eisting oGect areautomatically passed to any oGect derived from it.

07. !hat are the two components of #B ?1. An %!'# managerNadministrator and

2. %!'# driver.0;. !hat is the function of a #B manager ?

he %!'# (anager manages all the data sources that eists in the system.

05. !hat is the function of a #B ri$er ?

he %!'# !river allo&s the developer to talk to the ack end dataase.

Page 6: SQL Interview Question III

7/24/2019 SQL Interview Question III

http://slidepdf.com/reader/full/sql-interview-question-iii 6/6

06. !hat description of a data source is re<uired for #B ?he name of the !'(S the location of the source and the dataase dependent information.

0". 1ow is a connection establised by #B ?%!'# uses the description of the datasource availale in the %!'#.*0* file to load the

reHuired drivers to access that particular ack end dataase.