•
•
TableofContents
Index
MySQL®CertificationStudyGuide
ByPaulDuBois,StefanHinz,
CarstenPedersen
Publisher :SamsPublishing
PubDate :April15,2004
ISBN :0-672-32632-9
Pages :648
TheMySQLcertificationprogramisacarefully
developed,high-qualitycertificationprocess
thatcanhelpyouproveyourskillsinusing,
maintaining,andadministeringMySQL
databaseserversandothertechnologiesfrom
MySQLAB.
CoveringboththebasicMySQLCore
CertificationexamandtheadvancedMySQL
ProfessionalCertificationexam,MySQL
CertificationStudyGuideistheoneauthority
tolooktowhenyou'repreparingforeither
test.Thebookteachesyoualltheconcepts,
principles,andtechniquesthatyou'llneedto
knowfortheCoreandProfessional
certificationexams,anditincludesanarray
oflearningaids,practicequestions,andrealworldexamplestohelpyoupreparefortest
day.
•
•
TableofContents
Index
MySQL®CertificationStudyGuide
ByPaulDuBois,StefanHinz,
CarstenPedersen
Publisher :SamsPublishing
PubDate :April15,2004
ISBN :0-672-32632-9
Pages :648
Copyright
AbouttheAuthors
Acknowledgments
References
WeWanttoHearfromYou!
ReaderServices
Introduction
Foreword
AboutThisBook
ConventionsUsedinThisBook
AbouttheExams
SampleTables
OtherRelatedDocuments
InterpretingDESCRIBEOutput
Summary
Chapter1.MySQLandMySQLAB
Section1.1.TheDifferenceBetweenMySQLandMySQLAB
Section1.2.HowMySQLABOperates
Section1.3.MySQLCoreValues
Section1.4.MySQLDualLicensing
Section1.6.TheMySQLMailingLists
Section1.5.OrganizationandStructureoftheMySQLReferenceManual
Section1.7.Exercises
Chapter2.MySQLSoftware
Section2.1.MajorProgramComponentsUsedinMySQL
Section2.2.MajorOperatingSystemFamiliesSupportedbyMySQL
Section2.3.DifferencesBetweenMajorMySQLDistributions
Section2.4.AvailableMySQLClientInterfaces
Section2.5.Exercises
Chapter3.UsingMySQLClientPrograms
Section3.1.InvokingCommand-LineClientPrograms
Section3.2.ThemysqlClientProgram
Section3.4.Usingmysqldump
Section3.6.UsingMySQLCC
Section3.3.Usingmysqlimport
Section3.5.CheckingTableswithmysqlcheckandmyisamchk
Section3.7.MySQLConnectivityDrivers
Section3.8.Exercises
Chapter4.DataDefinitionLanguage
Section4.1.GeneralDatabaseandTableProperties
Section4.2.StorageEnginesandTableTypes
Section4.4.IdentifierSyntax
Section4.6.CREATETABLE
Section4.8.ALTERTABLE
Section4.10.ColumnTypes
Section4.3.LimitsonNumberandSizeofDatabaseComponents
Section4.5.CREATEDATABASEandDROPDATABASE
Section4.7.DROPTABLE
Section4.9.CreatingandDroppingIndexes
Section4.11.UsingSHOWandDESCRIBEtoReviewTableStructures
Section4.12.Exercises
Chapter5.TheSELECTStatement
Section5.1.IdentifyingWhatValuestoDisplay
Section5.2.RestrictingaSelectionUsingWHERE
Section5.4.LimitingaSelectionUsingLIMIT
Section5.3.UsingORDERBYtoSortQueryResults
Section5.5.AggregateFunctions,GROUPBY,andHAVING
Section5.6.UsingDISTINCTtoEliminateDuplicates
Section5.7.ConcatenatingSELECTResultswithUNION
Section5.8.Exercises
Chapter6.BasicSQL
Section6.1.UsingSQLExpressionsandFunctions
Section6.2.UsingLIKEforPatternMatching
Section6.3.UsingIN()toTestMembershipinaListofValues
Section6.5.UsingReservedWordsasIdentifiers
Section6.7.CommentsinSQLStatements
Section6.4.CaseSensitivityofIdentifiersandReservedWords
Section6.6.NULLValues
Section6.8.Exercises
Chapter7.UpdateStatements
Section7.1.TheINSERTandREPLACEStatements
Section7.2.TheUPDATEStatement
Section7.3.TheDELETEandTRUNCATETABLEStatements
Section7.4.Exercises
Chapter8.Joins
Section8.1.WritingInnerJoins
Section8.2.WritingOuterJoins
Section8.3.ConvertingSubqueriestoJoins
Section8.5.Multiple-TableUPDATEandDELETEStatements
Section8.4.ResolvingNameClashesUsingQualifiersandAliases
Section8.6.Exercises
Chapter9.ImportingandExportingData
Section9.1.TheLOADDATAINFILEStatement
Section9.2.TheSELECT…INTOOUTFILEStatement
Section9.3.DatafileFormatSpecifiers
Section9.4.ImportingandExportingNULLValues
Section9.5.Exercises
Chapter10.MySQLArchitecture
Section10.1.Client/ServerOverview
Section10.2.ChoosingtheRightClient
Section10.4.HowMySQLUsesDiskSpace
Section10.6.LogandStatusFiles
Section10.8.Exercises
Section10.3.ConnectingtheClienttotheServer
Section10.5.HowMySQLUsesMemory
Section10.7.MySQLStorageEngines
Chapter11.MySQLInstallationandConfiguration
Section11.1.RunningMySQLonWindows
Section11.3.RuntimeMySQLConfiguration
Section11.5.UpgradingMySQL
Section11.7.ConfiguringDisksforMySQLUse
Section11.2.RunningMySQLonUnix
Section11.4.CompilingMySQLfromaSourceDistribution
Section11.6.OptimizingtheOperatingSystemforMySQLUse
Section11.8.ChoosingHardwareforMySQLUse
Section11.9.Exercises
Chapter12.SecurityIssues
Section12.1.SecuringMySQL
Section12.2.UserAccountManagement
Section12.3.ClientAccessControl
Section12.4.Exercises
Chapter13.OptimizingforQuerySpeed
Section13.1.IndexOptimizationandIndexUsage
Section13.2.UsingEXPLAINtoAnalyzeQueries
Section13.4.OptimizingtheLogicalDatabaseStructure
Section13.3.GeneralQueryEnhancement
Section13.5.Exercises
Chapter14.MyISAMTables
Section14.1.SpecialMyISAMFeatures
Section14.2.MyISAM-SpecificOptimizations
Section14.3.MyISAMLockingStrategies
Section14.5.CheckingandRepairingMyISAMTables
Section14.4.MyISAMBackupandRecovery
Section14.6.MyISAMTableMaintenance
Section14.7.Exercises
Chapter15.InnoDBTables
Section15.1.TheInnoDBTablespaceandLogs
Section15.2.InnoDBTransactionSupport
Section15.4.InnoDB-SpecificOptimizations
Section15.6.CheckingandRepairingInnoDBTables
Section15.3.HowInnoDBUsesLocks
Section15.5.InnoDBBackupandRecovery
Section15.7.InnoDBMaintenance
Section15.8.Exercises
Chapter16.AdvancedServerFeatures
Section16.1.InterpretingmysqldServerInformation
Section16.2.TuningMemoryParameters
Section16.3.UsingtheQueryCache
Section16.5.Replication
Section16.4.UsingMultipleServers
Section16.6.Exercises
AppendixA.QuickReference
SectionA.1.SQLStatements
SectionA.2.SQLFunctions
SectionA.3.ColumnTypes
SectionA.4.ServerSystemVariables
AppendixB.MySQLCertificationCandidateGuide
SectionB.1.WhatIsaMySQLCertification?
SectionB.2.OtherSourcesofInformation
SectionB.4.RegisteringforExams
SectionB.6.HowtheExamsProceed
SectionB.8.StayingUpdated
SectionB.10.MySQL4CoreCertification
SectionB.12.PearsonVUEContactInformation
SectionB.3.TheMySQLCertificationProgram
SectionB.5.PreparingfortheExams
SectionB.7.AftertheExam
SectionB.9.HowLongAretheCertificationsValid?
SectionB.11.CertifiedMySQL4Professional
SectionB.13.MySQLABCertificationNDAandLUA
Index
Copyright
Copyright©2004byMySQLAB
Allrightsreserved.Nopartofthisbookshallbereproduced,
storedinaretrievalsystem,ortransmittedbyanymeans,
electronic,mechanical,photocopying,recording,orotherwise,
withoutwrittenpermissionfromthepublisher.Nopatent
liabilityisassumedwithrespecttotheuseoftheinformation
containedherein.Althougheveryprecautionhasbeentakenin
thepreparationofthisbook,thepublisherandauthorassume
noresponsibilityforerrorsoromissions.Norisanyliability
assumedfordamagesresultingfromtheuseoftheinformation
containedherein.
Theworldsampledatabase:CopyrightStatisticsFinland,
/>LibraryofCongressCatalogCardNumber:2003095797
PrintedintheUnitedStatesofAmerica
FirstPrinting:April2004
070605044321
Trademarks
Alltermsmentionedinthisbookthatareknowntobe
trademarksorservicemarkshavebeenappropriately
capitalized.Pearsoncannotattesttotheaccuracyofthis
information.Useofaterminthisbookshouldnotberegarded
asaffectingthevalidityofanytrademarkorservicemark.
WarningandDisclaimer
Everyefforthasbeenmadetomakethisbookascompleteand
asaccurateaspossible,butnowarrantyorfitnessisimplied.
Theinformationprovidedisonan"asis"basis.Theauthor(s)
andthepublishershallhaveneitherliabilitynorresponsibilityto
anypersonorentitywithrespecttoanylossordamagesarising
fromtheinformationcontainedinthisbook.
Anyerrataforthisbookarepublishedat
/>
BulkSales
SamsPublishingoffersexcellentdiscountsonthisbookwhen
orderedinquantityforbulkpurchasesorspecialsales.For
moreinformation,pleasecontact
U.S.CorporateandGovernmentSales
1-800-382-3419
ForsalesoutsideoftheU.S.,pleasecontact
InternationalSales
1-317-428-3341
Credits
ASSOCIATEPUBLISHER
MarkTaber
ACQUISITIONSEDITOR
ShelleyJohnston
DEVELOPMENTEDITOR
DamonJordan
MANAGINGEDITOR
CharlotteClapp
SENIORPROJECTEDITOR
TriciaLiebig
COPYEDITOR
MikeHenry
INDEXER
RebeccaSalerno
PROOFREADER
WendyOtt
MARKETINGMANAGER
RandiRoger
COVER&INTERIORDESIGNER
GaryAdair
PAGELAYOUT
MichelleMitchell
PUBLISHINGCOORDINATOR
VanessaEvans
MySQL®Pressistheexclusivepublisheroftechnologybooks
andmaterialsthathavebeenauthorizedbyMySQLAB.MySQL
Pressbooksarewrittenandreviewedbytheworld'sleading
authoritiesonMySQLtechnologies,andareedited,produced,
anddistributedbytheQue/SamsPublishinggroupofPearson
Education,theworldwideleaderinintegratededucationand
computertechnologypublishing.Formoreinformationon
MySQLPressandMySQLPressbooks,pleasegoto
www.mysqlpress.com.
MYSQLHQ
MySQLAB
Bangårdsgatan8
S-75320Uppsala
Sweden
UNITEDSTATES
MySQLInc.
2510FairviewAvenueEast
Seattle,WA98102
USA
GERMANY,AUSTRIA,ANDSWITZERLAND
MySQLGmbH
Schlosserstra e4
D-72622Nürtingen
Germany
FINLAND
MySQLFinlandOy
Tekniikantie21
FIN-02150Espoo
Finland
FRANCE
MySQLAB(France)
123,rueduFaubourgSt.Antoine
75011,Paris
France
MySQL®ABdevelops,markets,andsupportsafamilyofhighperformance,affordabledatabaseserversandtools.MySQLAB
isthesoleowneroftheMySQLserversourcecode,theMySQL
trademark,andthemysql.comdomain.Formoreinformation
onMySQLABandMySQLABproducts,pleasegoto
www.mysql.comorthefollowingareasoftheMySQLWebsite:
Traininginformation:www.mysql.com/training
Supportservices:www.mysql.com/support
Consultingservices:www.mysql.com/consulting
AbouttheAuthors
PaulDuBoisisamemberoftheMySQLdocumentationteam,
adatabaseadministrator,andaleaderintheOpenSourceand
MySQLcommunities.Hecontributedtotheonline
documentationforMySQLandistheauthorofMySQL
Developer'sLibrary,MySQLandPerlfortheWeb(NewRiders
Publishing),andMySQLCookbook,Usingcshandtcsh,and
SoftwarePortabilitywithimake(O'ReillyandAssociates).
StefanHinzisamemberoftheMySQLdocumentationteam,a
MySQLtrainerandconsultant,andtheGermantranslatorofthe
MySQLReferenceManual.HeisalsothetranslatorofPaul's
MySQLCookbook(O'ReillyandAssociates)andtranslatorand
authorofMySQL-relatedGermanbooks.Stefanpassedthe
MySQLCertificationexambeforehejoinedMySQLAB.
CarstenPedersenistheMySQLABCertificationManager,and
hasledthedevelopmentoftheMySQLCertificationProgram.
HehastaughtseveralMySQLcoursesinanumberofcountries.
BeforejoiningMySQLAB,headministeredMySQLdatabasesin
severalproductionsystemsandmaintainedaverypopular
"MySQLFAQandTools"Internetsite.
Acknowledgments
WewouldliketothankallofourcolleaguesatMySQLwhohave
helpedbuildthecertificationprogramoverthepast18months,
andwithoutwhomthisbookwouldn'thavecomeintoexistence.
AspecialthankyoutoKajArnö,whowasthepersonto
conceiveandinitiatetheMySQLCertificationprogram.
References
TheMySQLReferenceManualistheprimarysourceof
informationonMySQL.Itisavailableonlineinseveralformats
andlanguagesfromtheMySQLABWebsite
(Itisalsoavailableasaprinted
boundvolumefromMySQLPressinEnglishandfromMITPin
German.
TheportalssectionattheMySQLABWebsiteprovides
descriptionsofanumberofMySQL-relatedbooks.Thesemight
behelpfulinsupplementingthematerialintheMySQL
ReferenceManual,andmanyofthemalsodealwithspecific
topicsnotextensivelycoveredbythemanual,suchasWebsite
development,e-commerce,andapplicationprogrammingusing
theCclientlibraryorotherAPIs.
WeWanttoHearfromYou!
Asthereaderofthisbook,youareourmostimportantcritic
andcommentator.Wevalueyouropinionandwanttoknow
whatwe'redoingright,whatwecoulddobetter,whatareas
you'dliketoseeuspublishin,andanyotherwordsofwisdom
you'rewillingtopassourway.
Youcanemailorwritemedirectlytoletmeknowwhatyoudid
ordidn'tlikeaboutthisbookaswellaswhatwecandotomake
ourbooksstronger.
PleasenotethatIcannothelpyouwithtechnicalproblems
relatedtothetopicofthisbook,andthatduetothehigh
volumeofmailIreceive,Imightnotbeabletoreplytoevery
message.
Whenyouwrite,pleasebesuretoincludethisbook'stitleand
authoraswellasyournameandphoneoremailaddress.Iwill
carefullyreviewyourcommentsandsharethemwiththeauthor
andeditorswhoworkedonthebook.
Email:
Mail:
MarkTaber
AssociatePublisher
SamsPublishing
800East96thStreet
Indianapolis,IN46240USA
ReaderServices
FormoreinformationaboutthisbookorothersfromSams
Publishing,visitourWebsiteatwww.samspublishing.com.Type
theISBN(excludinghyphens)orthetitleofthebookinthe
Searchboxtofindthebookyou'relookingfor.
Introduction
Foreword
AboutThisBook
ConventionsUsedinThisBook
OtherRelatedDocuments
AbouttheExams
InterpretingDESCRIBEOutput
SampleTables
Summary
Foreword
AlthoughtheMySQL™RelationalDatabaseManagement
System(RDBMS)hasexistedformanyyears,it'sonlywithin
thelasttwoyearsthatMySQLhasgainedofficialrecognitionin
manyenterprisesettings.Thegrowthhasbeentremendousin
justafewyears,thenumberofMySQLinstallationsworldwide
hasrisenfromafewhundredthousandtoanestimatedfour
millioninearly2003.
ThegrowthofMySQLintheenterprise,pairedwithdownturnin
theeconomyattheturnofthecentury,hascreatedanew
phenomenon:Therearemorecompaniesthaneverlooking
specificallyforpeoplewithMySQLskills.Atthesametime,
manypeoplewithMySQLknowledgeareoutlookingforajob
aftertheburstofthedot-combubble,whichmeansthat
companiesinterestedinhiringcanpickandchooseatwill.
MySQLAB,thecompanybehindtheMySQLRDBMS(yes,even
thoughtheMySQLRDBMSisanopensourceproduct,there'sa
thrivingcompanybehindit)developedtheMySQLCertification
Programtohelpcompaniesidentifyindividualswiththeskillset
theyneedandexpectfromtheiremployees.Thecertification
programalsohelpsindividualsbysettingthemapartfrom
hobbyists,increasingtheirprospectsforfindingchallengingnew
tasks.
MySQLABcurrentlyofferscertificationattwolevels:
TheCoreCertificationtestsbasicMySQLknowledgeand
usage,knowledgethat'ssufficienttomaintainabasic
MySQLinstallationandtocreateapplicationprogramsthat
useMySQLasabackenddatabase.
TheProfessionalCertificationgoesintomoredetail
regardingsuchtopicsaslargetablemaintenance,storage
engines,andoptimizations.
Thisbookmeetsthedemandthatwascreatedbythe
introductionoftheMySQLCertificationProgram.Howdoyou
preparefortheexams?Readingthisstudyguideisthebestway
toenhanceyourchancesofpassingthedemandingMySQLCore
andProfessionalexams.
Althoughthetopicscoveredbyeachexam(aslistedinthe
"MySQLCertificationCandidateGuide")mightseembasic,the
examsaren'teasy,andtheyrequireacombinationofstudyand
practicalexperience.Thisbookwillhelpyouunderstandmany
ofthesetopicsin-depth.Combinedwithreal-worldexperience,
thiswillhelpyoupasstheexams.
Anothermeansofgainingskillsandknowledgetobothhelpyou
passtheexamsandbesuccessfulinthefieldofMySQL
administrationandusageistoattendoneormoreofthe
coursesprovidedbyMySQLAB.
MoreinformationontheMySQLtrainingandcertification
programsmaybefoundontheMySQLABWebsite(see
).
IwouldliketothankPaulDuBois,StefanHinz,andCarsten
Pedersenforbringingthisbookintoexistence.Thankyouto
TrudyPelzer,whoreviewedandeditedallexercisesaswellas
largepartsofthetext.Alsothankyoutothefollowingpeople,
eachofwhomhasreviewedandgivenextensivecommentson
thetext:ThomasBassel,JeremyCole,BobDonahue,Jason
Frisvold,PeterGulutzan,MikeHillyer,ArjenLentz,MaxMether,
HeikkiTuuri,NilsValentin,andPeterZaitsev.
Iamhappythebookisnowout.MySQLABnowhasan
excellentanswertothemostfrequentquestionwegetabout
certification,namely,"HowdoIbestprepareforit?"
Goodluckonyourexam!
KajArnö,MySQLAB,VicePresident,ProfessionalServices
AboutThisBook
ThisisastudyguidefortheMySQLCoreandProfessional
Certificationexams.Itcontainsboththe"CoreStudyGuide"
andthe"ProfessionalStudyGuide."Itshouldbeseenasa
primerfortheexams,butnotasareplacementfortheMySQL
ReferenceManual.Thisguideisnotmeantasanexhaustive
expositionofeverythingthereistoknowaboutMySQL.
Instead,itfocusesspecificallyontopicsthatappearonthe
examsandinMySQLtrainingclasses.Aspartofyour
preparationforanexam,youshouldofcoursemakesurethat
you'rethoroughlyfamiliarwiththeMySQLReferenceManual.In
addition,the"ProfessionalStudyGuide"assumesthatyou're
familiarwitheverythinginthe"CoreStudyGuide."
Youmightfindthatthewordingofatopiccoveredinthisguide
correspondsexactlytothewordingofaquestiononanexam.
However,thatistheexception,sorotememorizationofthe
materialinthisguidewillnotbeeffective.You'llneedto
understandtheprinciplesdiscussedhereinsothatyoucan
applythemtotheexamquestions.Ifyoufindthematerial
difficult,youmightwanttoconsiderthetrainingclassesoffered
byMySQLAB.Theseclassesarepresentedinaformatthat
facilitatesunderstandingbyallowingyoutointeractwiththe
instructor.
SomefeaturesinMySQLareversionspecific.Thecurrentexam
andthisbookcoverMySQL4,andyoushouldconsidera
featureavailableifit'savailableasofMySQL4.Forexample,
UNIONstatementswereimplementedforMySQL4.Forpurposes
oftheexam,youshouldconsiderUNIONatopicuponwhichyou
mightbetested.Morespecifically,youshouldexpecttobe
testedonagivenfeatureshortlyafteritappearsinagamma
versionofaMySQLrelease.Inpractice,however,thefeatures
testedinexamsarelikelytolagamonthortwobehindthe
releasedateofsuchagammaversion.
BecausethestudyguideistargetedtoMySQL4,itdoesn't
normallypointoutwhenfeaturesareunavailableinearlier
versions.Thisdiffersfromwhatyoumightbeusedtointhe
MySQLReferenceManual.Forexample,theInnoDBstorage
enginerequiresexplicitconfigurationinMySQL3.23,butnotin
MySQL4.TheMySQLReferenceManualpointsoutthat
difference.Incontrast,thisstudyguidesimplyindicatesthat
InnoDBusesdefaultconfigurationvaluesifyoudonotprovide
themexplicitlybecausethatisalwaystrueinMySQL4.
Thisintroductionprovidessomegeneralhintsonwhattoexpect
fromtheexam,whattodoinordertotaketheexam,what
happensonthedayoftheexam,andwhathappensonceyou
havepassedtheexam.
Theremainderofthisstudyguidecoverseachsectionofthe
exams,asdefinedinthe"MySQLCertificationCandidate
Guide."Theappendixesincludethe"CandidateGuide"itselfand
a"QuickReference."
Eachchapterendswithanumberofsampleexercises.It's
essentialthatyouworkthroughtheexercisestotestyour
knowledge.Doingsowillprepareyoutotaketheexamfar
betterthanjustreadingthetext.Anotherreasontoreadthe
exercisesisthatoccasionallytheyaugmentatopicwithmore
detailthanisgiveninthebodyofthechapter.
Notethattheexercisesarenotalwaysinthesameformatas
theexamquestions.Theexamquestionsareinaformatthatis
suitedfortestingyourknowledge.Theexercisesaredesigned
tohelpyougetabetterunderstandingofthecontentsofthis
book,andtohelpyouprovetoyourselfthatyoureallygrasp
thetopicscovered.
ConventionsUsedinThisBook
Thissectionexplainstheconventionsusedinthisstudyguide.
Textinthisstyleisusedforprogramandshellscript
names,SQLkeywords,andcommandoutput.
Textinthisstylerepresentsinputthatyouwouldtype
whileenteringacommandorstatement.
Textinthisstylerepresentsvariableinputforwhichyou're
expectedtoenteravalueofyourownchoosing.Some
examplesshowcommandsorstatementsthataren'tmeantto
beenteredexactlyasshown.Thus,inanexamplesuchasthe
following,youwouldsubstitutethenameofsomeparticular
tablefortable_name:
SELECT*FROMtable_name;
Insyntaxdescriptions,squarebracketsindicateoptional
information.Forexample,thefollowingsyntaxfortheSHOW
TABLESstatementindicatesthatyoucaninvokethestatement
withorwithoutaFROMclausethatspecifiesadatabasename:
SHOWTABLES[FROMdb_name]
Inmostcases,SQLstatementsareshownwithatrailing
semicoloncharacter(;).Thesemicolonindicateswherethe
statementendsandisusefulparticularlyinreadingmultiplestatementexamples.However,thesemicolonisnotpartofthe
statementitself.
Ifastatementisshowntogetherwiththeoutputthatit
produces,it'sshownprecededbyamysql>prompt.Anexample
showninthismannerismeanttoillustratetheoutputyou
wouldseewereyoutoissuethestatementusingthemysql
clientprogram.Forexample,asectionthatdiscussestheuseof
theVERSION()functionmightcontainanexamplelikethis:
mysql>SELECTVERSION();
+------------------+
|VERSION()|
+------------------+