SQL Interview Questions - Javatpoint
SQL Interview Questions - Javatpoint
ContentMenu
SQLInterviewQuestions
Thereisgivensqlinterviewquestionsandanswersthathas
beenaskedinmanycompanies.ForPL/SQLinterviewquestions,
visitournextpage.
1)WhatisSQL?
SQLstandsforstructuredquerylanguage.Itisadatabase
languageusedfordatabasecreation,deletion,fetchingrowsand
modifyingrowsetc.sometimesitispronouncedasseqwell.
2)WhenSQLappeared?
Itappearedin1974.
3)WhataretheusagesofSQL?
Toexecutequeriesagainstadatabase
Toretrievedatafromadatabase
Toinsertsrecordsinadatabase
Toupdatesrecordsinadatabase
Todeleterecordsfromadatabase
Tocreatenewdatabases
Tocreatenewtablesinadatabase
Tocreateviewsinadatabase
4)DoesSQLsupportprogramming?
No,SQLdoesn'thavelooporConditionalstatement.Itisused
likecommandinglanguagetoaccessdatabases.
5)WhatarethesubsetsofSQL?
1.Datadefinitionlanguage(DDL)
2.Datamanipulationlanguage(DML)
http://www.javatpoint.com/sqlinterviewquestions 1/6
3/8/2016 SQLInterviewQuestionsjavatpoint
3.Datacontrollanguage(DCL)
6)Whatisdatadefinitionlanguage?
Datadefinitionlanguage(DDL)allowsyoutoCREATE,ALTERand
DELETEdatabaseobjectssuchasschema,tables,view,
sequenceetc.
7)Whatisdatamanipulationlanguage?
Datamanipulationlanguagemakesuserabletoaccessand
manipulatedata.Itisusedtoperformfollowingoperations.
Insertdataintodatabase
Retrievedatafromthedatabase
Updatedatainthedatabase
Deletedatafromthedatabase
8)Whatisdatacontrollanguage?
Datacontrollanguageallowsyoutocontrolaccesstothe
database.ItincludestwocommandsGRANTandREVOKE.
GRANT:tograntspecificusertoperformspecifictask.
REVOKE:tocancelpreviouslydeniedorgrantedpermissions.
9)Whatarethetypeofoperatorsavailablein
SQL?
1.Arithmeticoperators
2.Logicaloperators
3.Comparisonoperator
10)Whatisthedifferencebetweenclustered
andnonclusteredindexinSQL?
http://www.javatpoint.com/sqlinterviewquestions 2/6
3/8/2016 SQLInterviewQuestionsjavatpoint
TherearemainlytwotypeofindexesinSQL,Clusteredindex
andnonclusteredindex.Thedifferencesbetweenthesetwo
indexesisveryimportantfromSQLperformanceperspective.
1)Onetablecanhaveonlyoneclusteredindexbutitcanhave
manynonclusteredindex.(approximately250).
2)clusteredindexdetermineshowdataisstoredphysicallyin
table.Actuallyclusteredindexstoresdataincluster,related
dataisstoredtogethersoitmakessimpletoretrievedata.
3)readingfromaclusteredindexismuchfasterthanreading
fromnonclusteredindexfromthesametable.
4)clusteredindexsortandstoredatarowsinthetableorview
basedontheirkeyvalue,whilenonclusterhaveastructure
separatefromthedatarow.
11)WhatistheSQLquerytodisplaycurrent
date?
ThereisabuiltinfunctioninSQLcalledGetDate()whichisused
toreturncurrenttimestamp.
12)WhichtypesofjoinisusedinSQLwidely?
TheknowledgeofJOINisverynecessaryforaninterviewee.
MostlyusedjoinisINNERJOINand(left/right)OUTERJOIN.
13)Whatis"TRIGGER"inSQL?
TriggerallowsyoutoexecuteabatchofSQLcodewhenan
insert,updateordeletecommandisexecutedagainstaspecific
table.
Actuallytriggersarespecialtypeofstoredproceduresthatare
definedtoexecuteautomaticallyinplaceorafterdata
modifications.
http://www.javatpoint.com/sqlinterviewquestions 3/6
3/8/2016 SQLInterviewQuestionsjavatpoint
14)Whatisselfjoinandwhatisthe
requirementofselfjoin?
Selfjoinisoftenveryusefultoconvertahierarchicalstructure
toaflatstructure.Itisusedtojoinatabletoitselfaslikeif
thatisthesecondtable.
15)WhataresetoperatorsinSQL?
Union,intersectorminusoperatorsarecalledsetoperators.
16)Whatisaconstraint?Tellmeaboutits
variouslevels.
Constraintsarerepresentatorsofacolumntoenforcedata
entityandconsistency.Therearetwolevels:
1.columnlevelconstraint
2.tablelevelconstraint
17)WriteanSQLquerytofindnamesof
employeestartwith'A'?
1. SELECT*FROMEmployeesWHEREEmpNamelike'A%'
18)WriteanSQLquerytogetthirdmaximum
salaryofanemployeefromatablenamed
employee_table.
1. SELECTTOP1salary
2. FROM(
3. SELECTTOP3salary
4. FROMemployee_table
5. ORDERBYsalaryDESC)ASemp
6. ORDERBYsalaryASC
http://www.javatpoint.com/sqlinterviewquestions 4/6
3/8/2016 SQLInterviewQuestionsjavatpoint
19)WhatisthedifferencebetweenDELETE
andTRUNCATEstatementinSQL?
ThemaindifferencesbetweenSQLDELETEandTRUNCATE
statementsaregivenbelow:
2) WecanuseWHERE WecannotuseWHERE
clauseinDELETE clausewithTRUNCATE
command.
3) DELETEstatementis TRUNCATEstatementisused
usedtodeletearow toremovealltherowsfrom
fromatable atable.
4) DELETEisslowerthan TRUNCATEstatementisfaster
TRUNCATEstatement. thanDELETEstatement.
5) Youcanrollbackdata Itisnotpossibletorollback
afterusingDELETE afterusingTRUNCATE
statement. statement.
20)WhatisACIDpropertyindatabase?
ACIDpropertyisusedtoensurethatthedatatransactionsare
processedreliablyinadatabasesystem.
Asinglelogicaloperationofadataiscalledtransaction.
ACIDisanacronymforAtomicity,Consistency,Isolation,
Durability.
Atomicity:itrequiresthateachtransactionisallornothing.It
meansifonepartofthetransactionfails,theentiretransaction
failsandthedatabasestateisleftunchanged.
Consistency:theconsistencypropertyensurethatthedata
mustmeetallvalidationrules.Insimplewordsyoucansaythat
yourtransactionneverleavesyourdatabasewithoutcompleting
itsstate.
http://www.javatpoint.com/sqlinterviewquestions 5/6
3/8/2016 SQLInterviewQuestionsjavatpoint
Isolation:thispropertyensurethattheconcurrentpropertyof
executionshouldnotbemet.Themaingoalofproviding
isolationisconcurrencycontrol.
Durability:durabilitysimplymeansthatonceatransactionhas
beencommitted,itwillremainso,comewhatmayevenpower
loss,crashesorerrors.
JavaBasics JavaOOPsInterview
InterviewQuestions Questions
JavaMultithreading JavaString&Exception
InterviewQuestions InterviewQuestions
JavaCollection JDBCInterview
InterviewQuestions Questions
ServletInterview JSPInterview
Questions Questions
SpringInterview HibernateInterview
Questions Questions
PL/SQLInterview SQLInterview
Questions Questions
OracleInterview AndroidInterview
Questions Questions
SQLServerInterview MySQLInterview
Questions Questions
http://www.javatpoint.com/sqlinterviewquestions 6/6