Вы находитесь на странице: 1из 7

Software testing - Questions and Answers - SQL Interview Questions

1. Q. What does SQL stand for?


A. Structured Query Language
2. Q. How do you select all records fro the ta!le?
A. Select " fro ta!le#nae$
%. Q. How do you add record to a ta!le?
A. I&S'() into ta!le#nae *AL+'S ,1 - .a!cd/ -/0dh0dfhg/1$
2. Q. How do you add a colun to a ta!le?
A. AL)'( )A3L' 4e5artent
A44 ,A6'- &+73'(1$
8. Q. How do you change value of the field?
A. +94A)' '79#ta!le
set nu!er : 2;;
where ite#un!er : 1
u5date nae#ta!le set status : <ena!le< where 5hone : <%181112222<$
u5date S'(*I='#ta!le set ('Q+'S)#4A)' : to#date ,<2;;8-;>-;% ;?@2?<- <yyyy--dd
hh2%@7I<1 where 5hone : <%181112222<$
A. Q. What does =B77I) do?
A. Saving all changes ade !y 47L stateents
?. Q. What is a 5riary Cey?
A. )he colun ,coluns1 that has co5letely uniDue data throughout
the ta!le is Cnown as the 5riary Cey field.
1;. Q. What are foreign Ceys?
A. Eoreign Cey field FG. is a field that linCs one ta!le
to another ta!leFGHs 5riary or foreign Cey.
11. Q. What is the ain role of a 5riary Cey in a ta!le?
A. )he ain role of a 5riary Cey in a data ta!le is to aintain the internal integrity of a data
ta!le.
12. Q. =an a ta!le have ore than one foreign Cey defined?
A. A ta!le can have any nu!er of foreign Ceys defined. It can have only
one 5riary Cey defined.
1>. Q. List all the 5ossi!le values that can !e stored in a 3BBL'A& data field.
A. )here are only two values that can !e stored in a 3BBL'A& data field@
-1,true1 and ;,false1.
1% Q. What is the highest value that can !e stored in a 3I)' data field?
A. )he highest value that can !e stored in a 3I)' field is 222. or fro -12A
to 12J. 3yte is a set of 3its that re5resent a single character.
+sually there are A 3its in a 3yte- soeties ore- de5ending on how
the easureent is !eing ade. 'ach =har reDuires one !yte of eory
and can have a value fro ; to 222 ,or ; to 11111111 in !inary1.
12. Q. How any 5laces to the right of the decial can !e stored in a
=+(('&=I data field?
A. )he =+(('&=I data ty5e can store u5 to four 5laces to the right of the
decial. Any data !eyond the fourth 5lace will !e truncated !y *isual
3asic without re5orting an error.
18. Q. What is a stored 5rocedure?
A. A 5rocedure is a grou5 of 9LKSQL stateents that can !e called !y
a nae. 9rocedures do not return values they 5erfor tasCs.
1J. Q. 4escri!e how &+LLs worC in SQL?
A. )he &+LL is how SQL handles issing values.
Arifthetic o5eration with &+LL in SQL will return a &+LL.
1A. Q. What is &oraliLation?
A. )he 5rocess of ta!le design is called noraliLation.
1?. Q. What is referential integrity constraints?
A. (eferential integrity constraints are rules
that are 5artnof the ta!le in a data!ase schea.
2;. Q. What is )rigger?
A. )rigger will eMecute a !locC of 5rocedural code
against the data!ase when a ta!le event occurs.
A2. A trigger defines a set of actions that are 5erfored in res5onse
to an insert- u5date- or delete o5eration on a s5ecified ta!le. When
such an SQL o5eration is eMecuted- in this case the trigger has !een
activated.
21. Q. Which of the following WH'(' clauses will return only rows
that have a &+LL in the 9er4ie'M5enses colun?
A. WH'(' 9er4ie'M5enses NO
3. WH'(' 9er4ie'M5enses IS &+LL
=. WH'(' 9er4ie'M5enses : &+LL
4. WH'(' 9er4ie'M5enses &B) I& ,"1
A. 3 is correct

22. Q. Iou issue the following Duery@
S'L'=) Eirst&ae E(B7
StaffList WH'(' Eirst&ae LIP'<#AQ<
Which naes would !e returned !y this Duery? =hoose all that a55ly.
A. Allen
3. =LA(P
=. RA=PSB&
4. 4avid
A. = is correct STU )wo wildcards are used with the LIP' o5erator.
)he underscore ,#1 stands for any one character of any
case- and the 5ercent sign ,Q1 stands for any nu!er of
characters of any case including none. 3ecause this string
starts with an underscore rather than a 5ercent sign- it won<t
return Allen or =larC !ecause they re5resent Lero and two
characters !efore the VAV. If the LIP' string had !een VQAQV-
!oth of these values would have !een returned.
4avid was not returned !ecause all non-wild card characters
are case sensitive. )herefore- only strings
with an u55ercase VAV as their second letter are returned
2>. Q. Write a SQL S'L'=) Duery that only returns each city only once fro Students ta!le?
4o you need to order this list with an B(4'( 3I clause?
A. S'L'=) 4IS)I&=) =ity
E(B7 Students$
)he 4istinct Ceyword autoatically sorts all data
in ascending order. However- if you want the data
sorted in descending order- you have to use an B(4'( 3I clause
2%. Q. Write a SQL S'L'=) sa5le of the concatenation o5erator.
A. S'L'=) Last&ae WW<-< WW Eirst&ae- =ity E(B7 Students$
22. Q. How to renae colun in the SQL S'L'=) Duery?
A. S'L'=) Last&ae WW<-< WW Eirst&ae
AS VStudent &aeV- =ity AS VHoe =ityV
VE(B7 StudentsB(4'( 3I VStudent &aeV
28. Q. Write SQL S'L'=) eMa5le how you liiting the rows returned with a WH'(' clause.
A. S'L'=) InstructorI4- Salary E(B7 Instructors
WH'(' Salary O 2%;; A&4 Salary N 88;;$
2J. Q. Write SQL S'L'=) Duery that returns the first and
last nae of each instructor- the Salary-
and gives each of the a nu!er.
A. S'L'=) Eirst&ae- Last&ae- Salary-
(BW&+7 E(B7 Instructors$
2A. Q. Which of the following functions can !e used only with nueric values?
,=hoose all that a55ly.1
A. A*6
3. 7I&
=. L'&6)H
4. S+7
'. (B+&4
A. A and 4 STU Bnly A and 4 are correct. )he 7I& function
worCs with any character- nueric- or date dataty5e.
)he L'&6)H function is a character function that returns
the nu!er of letters in a character value. )he (B+&4
function worCs with !oth nueric and date values.
2?. Q. Which function do you use to reove all 5added characters
to the right of a character value in a colun with a char dataty5e?
A. ()(I7
3. (9A4
=. )(I7
A. = STU )he )(I7 function is used to reove 5added s5aces.
L)(I7 and ()(I7 functions were included in earlier versions
of Bracle- !ut Bracle Ai has re5laced the with a single
)(I7 function
>;. Q. Which stateent do you use to eliinate 5added s5aces
!etween the onth and day values in a function )B#=HA(,SIS4A)'-<7onth- 44- IIII<1 ?
A. )o reove 5added s5aces- you use the VfV
5refiM !efore the date eleent that contains the s5aces.
)B#=HA(,SIS4A)'-<f7onth 44- IIII<1
>1. Q. Is the WH'(' clause ust a55ear always !efore the 6(B+9 3I clause in SQL S'L'=) ?
A. Ies.
)he 5ro5er order for SQL S'L'=)
clauses is@ S'L'=)- E(B7- WH'('- 6(B+9 3I- HA*I&6- B(4'( 3I.
Bnly the S'L'=) and E(B7 clause are andatory.
>2. Q. How Bracle eMecutes a stateent with nested su!Dueries?
A. When Bracle eMecutes a stateent with nested su!Dueries-
it always eMecutes the innerost Duery first. )his Duery 5asses its
results to the neMt Duery and so on until it reaches the outerost Duery.
It is the outerost Duery that returns a result set.
>>. Q. Which o5erator do you use to return all of the rows
fro one Duery eMce5t rows are returned in a second Duery?
A. Iou use the 7I&+S o5erator to return all rows fro one Duery eMce5t
where du5licate rows are found in a second Duery. )he +&IB& o5erator
returns all rows fro !oth Dueries inus du5licates. )he +&IB& ALL o5erator
returns all rows fro !oth Dueries including du5licates.
)he I&)'(S'=) o5erator returns only those rows that eMist in !oth Dueries.
>%. Q. How you will create a colun alias? ,Bracle Ai1
A. )he AS Ceyword is o5tional when s5ecifying a colun alias.
Iou ust enclose the colun alias in dou!le Duotes when the alias
contains a s5ace or lowercase letters. If you s5ecify an alias in l
owercase letters without dou!le Duotes- the alias will a55ear in u55ercase.
>2 Q. Which of the following stateents are 4ata 7ani5ulation Language coands?
A. I&S'()
3. +94A)'
=. 6(A&)
4. )(+&=A)'
'. =('A)'
A. A and 3 STU )he I&S'() and +94A)' stateents are
4ata 7ani5ulation Language ,47L1 coands.
6(A&) is a 4ata =ontrol Language ,4=L1 coand.
)(+&=A)' and =('A)' are 4ata 4efinition Language ,44L1 coands
>8. Question. What is Bracle locCing?
A. Bracle uses locCing echaniss to 5rotect data fro
!eing destroyed !y concurrent transactions.
>J. Question. What Bracle locC odes do you Cnow?
A. Bracle has two locC odes@ shared or eMclusive.
Shared locCs are set on data!ase resources so that any transactions
can access the resource.
'Mclusive locCs are set on resources that ensure
one transaction has eMclusive access to the data!ase resource
>A. Question. What is Duery o5tiiLation?
A. Query o5tiiLation is the 5art of the Duery
5rocess in which the data!ase syste co5ares
different Duery strategies and chooses the one with
the least eM5ected cost
>?. Question. What are the ain co5onents of 4ata!ase anageent systes software.
A. )he data!ase anageent syste software includes
co5onents for storage anageent- concurrency control- transaction
5rocessing- data!ase ani5ulation interface- data!ase definition interface-
and data!ase control interface.
%;. Question. What are the ain attri!utes of data!ase anageent syste?
A. A data!ase anageent syste is co5osed of five eleents@ co5uter hardware-
software- data- 5eo5le ,users1- and o5erations 5rocedures.
%1. Question. What is transaction?
A. A transaction is a collection of a55lications
code and data!ase ani5ulation code !ound into an indivisi!le unit of eMecution.
it consists fro@
3'6I&-)(A&SA=)IB& &ae
=ode
'&4 )(A&SA=)IB& &ae
%2. Question. What data!ases do you Cnow?
InforiM
432
SQL
Bracle
%>. Question. 'M5lain SQL S'L'=) eMa5le@
select 0.EIL'#&+7
fro 43#nae.0o! 0- 43#nae.address a
where 0.RB3#)I9' :<=<
A&4 0.=B79A&I#&A7' : <)'S)8<
A&4 0.BEEI='#I4 : <1;1<
A&4 0.A=)I*'#I&4 : <I<
A&4 a.A44('SS#S)A)+S#I4 : <H<
A&4 a.BEEI='#I4 : <1;1<
A&4 a.EIL'#&+7 : 0.EIL'#&+7 order !y 0.EIL'#&+7$
Answer@ 0 and a aliases for ta!le naes. this is outer 0oint select stataent fro two ta!les.
%%. Q. 4escri!e soe =onversion Eunctions that you Cnow
A. )B#=HA( converts a nu!er K date to a string.
)B#4A)' converts a string ,re5resenting a date1 to a date.
)B#&+73'( converts a character string containing digits to a nueric data ty5e- it acce5ts
one 5araeter which is a colun value or a string literal
%2. Q. 4escri!e soe 6rou5 Eunctions that you Cnow
A. 11 )he =B+&) function tells you how any rows were in the result set.
S'L'=) =B+&),"1 E(B7 )'S)I&6.QA
21 )he A*6 function tells you the average value of a nueric colun.
S'L'=) 7AX,SALA(I1 E(B7 )'S)I&6.QA
>1 )he 7AX and 7I& functions tell you the aMiu and iniu value of a nueric colun.
S'L'=) 7I&,SALA(I1 E(B7 )'S)I&6.QA
%1 )he S+7 function tells you the su value of a nueric colun.
S'L'=) S+7,SALA(I1 E(B7 )'S)I&6.QA
%8. Question. What does 47L stand for?
A. 47L is 4ata 7ani5ulation Language stateents. ,S'L'=)1
%J. Question. What does 44L stand for?
A. 44L is 4ata 4efinition Language stateents. ,=('A)'1
%A. Question. What does 4=L stand for?
A. 4=L is 4ata =ontrol Language stateents. ,=B77I)1
%?. Question@ 4escri!e SQL coents.
A. SQL coents are introduced !y two consecutive hy5hens
,--1 and ended !y the end of the line.
2;. Q. In what seDuence SQL stateent are 5rocessed?

A. )he clauses of the su!select are 5rocessed in the following seDuence ,4321@
1. E(B7 clause
2. WH'(' clause
>. 6(B+9 3I clause
%. HA*I&6 clause
2. S'L'=) clause
8. B(4'( 3I clause
J. E')=H EI(S) clause
21. Q. 4escri!e )B#4A)' function.
A. )he )B#4A)' function returns a tiesta5 fro a character string
that has !een inter5reted using a character te5late.
)B#4A)' is a synony for )I7'S)A79#EB(7A).
Bn this 5age I 5ut soe SQL interview Duestions. )hese SQL interview
Duestions are very si5le and ainly were used for interviewing software testers
who is involved in data!ase SQL testing or grey !oM testing. )he interview
Duestions found a!ove are listed in order of co5leMity. However all new
interview Duestions ,regardless of there difficulty1 will !e added to the !otto of
the list. Iou can find ore SQL interview Duestions searching the W'3.
'&4 3asic SQL interview Duestions.

Вам также может понравиться