Professional Documents
Culture Documents
SoftwareTestingHelp
SoftwareTestingCompleteGuide
CustomSearch Search
50PopularSQLInterviewQuestionsforTesters
Inthistutorial,wehavelistedthe50mostpopularlyaskedSQLinterviewquestionsfortesters.
BelowarethemostcommonandusefulSQLinterviewquestionsfortesterssothatyoucanpreparefor
interviewwhilelearningSQL.
SQLInterviewQuestions&Answers
Alsoread=>AllaboutDatabaseTesting
Q#1.WhatdoesSQLstandfor?
Ans.SQLstandsforStructuredQueryLanguage.
Q#2.Howtoselectallrecordsfromthetable?
Ans.Toselectalltherecordsfromthetableweneedtousefollowingsyntax:
Select*fromtable_name
Q#3.Definejoinandnamedifferenttypeofjoins?
Ans.Joinkeywordisusedtofetchdatafromrelatedtwoormoretables.Itreturnsrowswherethereisatleast
onematchinboththetablesincludedinjoin.Readmorehere.
Typeofjoinsare
1.RightJoin
2.OuterJoin
3.FullJoin
4.CrossJoin
5.SelfJoin.
Q#4.Whatisthesyntaxtoaddrecordtoatable?
Ans.ToaddrecordinatableINSERTsyntaxisused.
Ex:INSERTintotable_nameVALUES(value1,value2..)
Q#5.Howdoyouaddacolumntoatable?
Ans.Toaddanothercolumninthetablefollowingcommandhasbeenused.
ALTERTABLEtable_nameADD(column_name)
Q#6.DefineSQLDeletestatement.
Ans.Deleteisusedtodeletearoworrowsfromatablebasedonthespecifiedcondition.
Basicsyntaxisasfollows:
http://www.softwaretestinghelp.com/50popularsqlinterviewquestionsfortesters/ 1/8
5/16/2017 50PopularSQLInterviewQuestionsforTestersSoftwareTestingHelp
DELETEFROMtable_name
WHERE<Condition>
Q#7.DefineCOMMIT?
Ans.COMMITsavesallchangesmadebyDMLstatements.
Q#8.Whatisaprimarykey?
Ans.APrimarykeyiscolumnwhosevaluesuniquelyidentifyeveryrowinatable.Primarykeyvaluescan
neverbereused.
Q#9.Whatareforeignkeys?
Ans.Whenaonetablesprimarykeyfieldisaddedtorelatedtablesinordertocreatethecommonfieldwhich
relatesthetwotables,itcalledaforeignkeyinothertables.
ForeignKeyconstraintsenforcereferentialintegrity.
Q#10.WhatisCHECKConstraint?
Ans.ACHECKconstraintisusedtolimitthevaluesortypeofdatathatcanbestoredinacolumn.Theyare
usedtoenforcedomainintegrity.
Q#11.Isitpossibleforatabletohavemorethanoneforeignkey?
Ans.Yes,atablecanhavemanyforeignkeysandonlyoneprimarykey.
Q#12.WhatarethepossiblevaluesforBOOLEANdatafield.
Ans.ForaBOOLEANdatafieldtwovaluesarepossible:1(true)and0(false).
Q#13.Whatisastoredprocedure?
Ans.AstoredprocedureisasetofSQLquerieswhichcantakeinputandsendbackoutput.
Q#14.WhatisidentityinSQL?
Ans.AnidentitycolumnintheSQLautomaticallygeneratesnumericvalues.Wecandefinedastartand
incrementvalueofidentitycolumn.
Q#15.WhatisNormalization?
Ans.Theprocessoftabledesigntominimizethedataredundancyiscallednormalization.Weneedtodividea
databaseintotwoormoretableanddefinerelationshipsbetweenthem.
Q#16.WhatisTrigger?
Ans.TriggerallowsustoexecuteabatchofSQLcodewhenatableeventoccurs(Insert,updateordelete
commandexecutedagainstaspecifictable)
Q#17.Howtoselectrandomrowsfromatable?
Ans.UsingSAMPLEclausewecanselectrandomrows.
Example:
SELECT*FROMtable_nameSAMPLE(10)
Q#18.WhichTCP/IPportdoesSQLServerrun?
Ans.BydefaultSQLServerrunsonport1433.
Q#19.WriteaSQLSELECTquerythatonlyreturnseachnameonlyoncefromatable?
Ans.Togettheeachnameonlyonce,weneedtousetheDISTINCTkeyword.
SELECTDISTINCTnameFROMtable_name
http://www.softwaretestinghelp.com/50popularsqlinterviewquestionsfortesters/ 2/8
5/16/2017 50PopularSQLInterviewQuestionsforTestersSoftwareTestingHelp
Q#20.ExplainDMLandDDL?
Ans.DMLstandsforDataManipulationLanguage.INSERT,UPDATEandDELETEareDMLstatements.
DDLstandsforDataDefinitionLanguage.CREATE,ALTER,DROP,RENAMEareDDLstatements.
Q#21.CanwerenameacolumnintheoutputofSQLquery?
Ans.Yesusingthefollowingsyntaxwecandothis.
SELECTcolumn_nameASnew_nameFROMtable_name
Q#22.GivetheorderofSQLSELECT?
Ans.OrderofSQLSELECTclausesis:SELECT,FROM,WHERE,GROUPBY,HAVING,ORDERBY.Only
theSELECTandFROMclausearemandatory.
Q#23.SupposeaStudentcolumnhastwocolumns,NameandMarks.Howtogetnameandmarksoftop
threestudents.
Ans.SELECTName,MarksFROMStudents1where3<=(SELECTCOUNT(*)FROMStudentss2WHERE
s1.marks=s2.marks)
Q#24.WhatisSQLcomments?
Ans.SQLcommentscanbeputbytwoconsecutivehyphens().
Q#25.DifferencebetweenTRUNCATE,DELETEandDROPcommands?
Ans.DELETEremovessomeorallrowsfromatablebasedonthecondition.Itcanberolledback.
TRUNCATEremovesALLrowsfromatablebydeallocatingthememorypages.Theoperationcannotbe
rolledback
DROPcommandremovesatablefromthedatabasecompletely.
Q#26.Whatarethepropertiesofatransaction?
Ans.GenerallythesepropertiesarereferredasACIDproperties.Theyare:
1.Atomicity
2.Consistency
3.Isolation
4.Durability.
Q#27.WhatdoyoumeanbyROWID?
Ans.Itsa18characterlongpseudocolumnattachedwitheachrowofatable.
Q#28.DefineUNION,MINUS,UNIONALL,INTERSECT?
Ans.MINUSreturnsalldistinctrowsselectedbythefirstquerybutnotbythesecond.
UNIONreturnsalldistinctrowsselectedbyeitherquery
UNIONALLreturnsallrowsselectedbyeitherquery,includingallduplicates.
INTERSECTreturnsalldistinctrowsselectedbybothqueries.
Q#29.Whatisatransaction?
Ans.Atransactionisasequenceofcodethatrunsagainstadatabase.Ittakesdatabasefromoneconsistentstate
toanother.
http://www.softwaretestinghelp.com/50popularsqlinterviewquestionsfortesters/ 3/8
5/16/2017 50PopularSQLInterviewQuestionsforTestersSoftwareTestingHelp
Q#30.WhatisdifferencebetweenUNIQUEandPRIMARYKEYconstraints?
Ans.AtablecanhaveonlyonePRIMARYKEYwhereastherecanbeanynumberofUNIQUEkeys.
PrimarykeycannotcontainNullvalueswhereasUniquekeycancontainNullvalues.
Q#31.Whatisacompositeprimarykey?
Ans.Primarykeycreatedonmorethanonecolumniscalledcompositeprimarykey.
Q#32.WhatisanIndex?
Ans.AnIndexisanspecialstructureassociatedwithatablespeeduptheperformanceofqueries.Indexcanbe
createdononeormorecolumnsofatable.
Q#33.WhatistheSubquery?
Ans.ASubqueryissubsetofselectstatementswhosereturnvaluesareusedinfilteringconditionsofthemain
query.
Q#34.Whatdoyoumeanbyqueryoptimization?
Ans.Queryoptimizationisaprocessinwhichdatabasesystemcomparesdifferentquerystrategiesandselect
thequerywiththeleastcost.
Q#35.WhatisCollation?
Ans.Setofrulesthatdefineshowdataisstored,howcasesensitivityandKanacharactercanbetreatedetc.
Q#36.WhatisReferentialIntegrity?
Ans.Setofrulesthatrestrictthevaluesofoneormorecolumnsofthetablesbasedonthevaluesofprimarykey
oruniquekeyofthereferencedtable.
Q#37.WhatisCaseFunction?
Ans.CasefacilitatesifthenelsetypeoflogicinSQL.Itevaluatesalistofconditionsandreturnsoneof
multiplepossibleresultexpressions.
Q#38.Defineatemptable?
Ans.Atemptableisatemporarystoragestructuretostorethedatatemporarily.
Q#39.Howwecanavoidduplicatingrecordsinaquery?
Ans.ByusingDISTINCTkeywordduplicatingrecordsinaquerycanbeavoided.
Q#40.ExplainthedifferencebetweenRenameandAlias?
Ans.RenameisapermanentnamegiventoatableorcolumnwhereasAliasisatemporarynamegiventoa
tableorcolumn.
Q#41.WhatisaView?
Ans.Aviewisavirtualtablewhichcontainsdatafromoneormoretables.Viewsrestrictdataaccessoftableby
selectingonlyrequiredvaluesandmakecomplexquerieseasy.
Q#42.WhataretheadvantagesofViews?
Ans.AdvantagesofViews:
1.Viewsrestrictaccesstothedatabecausetheviewcandisplayselectivecolumnsfromthetable.
2.Viewscanbeusedtomakesimplequeriestoretrievetheresultsofcomplicatedqueries.Forexample,
viewscanbeusedtoqueryinformationfrommultipletableswithouttheuserknowing.
Q#43.Listthevariousprivilegesthatausercangranttoanotheruser?
Ans.SELECT,CONNECT,RESOURCES.
http://www.softwaretestinghelp.com/50popularsqlinterviewquestionsfortesters/ 4/8
5/16/2017 50PopularSQLInterviewQuestionsforTestersSoftwareTestingHelp
Q#44.Whatisschema?
Ans.AschemaiscollectionofdatabaseobjectsofaUser.
Q#45.WhatisTable?
Ans.Atableisthebasicunitofdatastorageinthedatabasemanagementsystem.Tabledataisstoredinrows
andcolumns.
Q#46.DoViewcontainData?
Ans.No,Viewsarevirtualstructure.
Q#47.CanaViewbasedonanotherView?
Ans.Yes,AViewisbasedonanotherView.
Q#48.WhatisdifferencebetweenHavingclauseandWhereclause?
Ans.BothspecifyasearchconditionbutHavingclauseisusedonlywiththeSELECTstatementandtypically
usedwithGROUPBYclause.
IfGROUPBYclauseisnotusedthenHavingbehaveslikeWHEREclauseonly.
Q#49.WhatisdifferencebetweenLocalandGlobaltemporarytable?
Ans.Ifdefinedininsideacompoundstatementalocaltemporarytableexistsonlyforthedurationofthat
statementbutaglobaltemporarytableexistspermanentlyinthedbbutitsrowsdisappearswhentheconnection
isclosed.
Q#50.WhatisCTE?
Ans.ACTEorcommontableexpressionisanexpressionwhichcontainstemporaryresultsetwhichisdefined
inaSQLstatement.
Conclusion:
Thatsallfornow.
HopeinthisarticleyouwillfindanswerstomostfrequentlyaskedSQLinterviewquestionsfortesters.The
knowledgeofSQLismustforanytesterandthisarticlewillhelpyouinpreparingSQLquestionforthe
interview.
HappyLearning..!!
Help&Tutorials
http://www.softwaretestinghelp.com/50popularsqlinterviewquestionsfortesters/ 5/8
5/16/2017 50PopularSQLInterviewQuestionsforTestersSoftwareTestingHelp
ISTQBStudyGuide
ISTQBPremiumStudyGuide
FreeQATraining
FreeSeleniumTraining
FreeQTPTraining
FreeQCTraining
HPLoadRunnerTutorials
JIRATutorials
101+InterviewQuestions
Followus!
62K 4K
8K 4K
10K 54K
37.4K 179K
Adv
http://www.softwaretestinghelp.com/50popularsqlinterviewquestionsfortesters/ 6/8
5/16/2017 50PopularSQLInterviewQuestionsforTestersSoftwareTestingHelp
DownloadFREE Search
"PracticalSoftware
Testing"eBookNow!
Aboutus|Articles|Contactus|Directory|Affiliates|Advertise|TestingServices
Enteremail:
Allarticlesarecopyrightedandcannotbereproducedwithoutpermission.
GetThiseBook
20062017SoftwareTestingHelpReadourCopyrightPolicy|Privacy
Policy|LinktoUs
Iwillneverspamyou!
RelatedPosts
Top50SQLServerInterviewQuestionforTesters
50BestSQLServerInterviewQuestionforTesters
31BestDatabaseTestingInterviewQuestionsandAnswersforQATesters
AllAboutDatabaseTestingWhytoTest,HowtoTest,andWhattoTest?
TopDatabaseTestingInterviewQuestionsAskedinanInterviewTestingQ&ASeries
ASimpleApproachforXMLtoDatabaseTesting
SQLInjectionHowtoTestWebApplicationsagainstSQLInjectionAttacks
HandlingWebTables,Frames,andDynamicElementsinSeleniumScriptSeleniumTutorial#18
OnlineTrainingbySTH
http://www.softwaretestinghelp.com/50popularsqlinterviewquestionsfortesters/ 7/8
5/16/2017 50PopularSQLInterviewQuestionsforTestersSoftwareTestingHelp
http://www.softwaretestinghelp.com/50popularsqlinterviewquestionsfortesters/ 8/8