D61762GC10_TOC_sg5

Embed Size (px)

Citation preview

  • 8/10/2019 D61762GC10_TOC_sg5

    1/20

    MySQL for Database Administrators

    Student Guide - Volum e I

    SQL-4502 Rev 2.2

    D61762GC10

    Edition 1.0

    D62341

  • 8/10/2019 D61762GC10_TOC_sg5

    2/20

    Copyright 2009, 2010, Oracle and/or its affiliates. All r ights reserved.

    Disclaimer

    This document contains proprietary information, is provided under a license agreement containing restrictions on use anddisclosure, and is protected by copyright and other intellectual property laws. You may copy and print this document solely for your own use in an Oracle training course. The document may not be modified or altered in any way. Except as expresslypermitted in your license agreement or allowed by law, you may not use, share, download, upload, copy, print, display,perform, reproduce, publish, license, post, transmit, or distribute this document in whole or in part without the expressauthorization of Oracle.

    The information contained in this document is subject to change without notice. If you find any problems in the document,please report them in writing to: Oracle University, 500 Oracle Parkway, Redwood Shores, California 94065 USA. Thisdocument is not warranted to be error-free.

    Sun Microsyst ems, Inc. Disclaimer

    This training manual may include references to materials, offerings, or products that were previously offered by SunMicrosystems, Inc. Certain materials, offerings, services, or products may no longer be offered or provided.Oracle and itsaffiliates cannot be held responsible for any such references should they appear in the text provided.

    Restricted Rights Notice

    If this documentation is delivered to the U.S. Government or anyone using the documentation on behalf of the U.S.Government, the following notice is applicable:

    U.S. GOVERNMENT RIGHTSThe U.S. Governments rights to use, modify, reproduce, release, perform, display, or disclose these training materials arerestricted by the terms of the applicable Oracle license agreement and/or the applicable U.S. Government contract.

    Trademark Notic e

    Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respectiveowners.

    AMD, Opteron, the AMD logo, and the AMD Opteron logo are trademarks or registered trademarks of Advanced MicroDevices. Intel and Intel Xeon are trademarks or registered trademarks of Intel Corporation. All SPARC trademarks are usedunder license and are trademarks or registered trademarks of SPARC International, Inc. UNIX is a registered trademarklicensed through X/Open Company, Ltd.

  • 8/10/2019 D61762GC10_TOC_sg5

    3/20

    MySQL for Database Administrators Preface

    MySQL for Database Administrators St$dent ($ide

    This is the Student guide for the MyS ! for "ata#ase $dministrators training course. This guide was de%elo&edusing the MyS ! '.0 and/or MyS ! '.( )ommunity *dition + enerally $%aila#le - $ eleases.

    iii

  • 8/10/2019 D61762GC10_TOC_sg5

    4/20

    MySQL for Database Administrators Preface

    -onventions $sed in t.is trainin& &$ide

    The following ty&ogra&hical con%entions are used throughout this training guide4

    )om&uter in&ut and out&ut is &rinted in this format4 Computer input or output . This is also usedfor the names of e9ecuta#le &rograms and file locations.

    :eywords from the S ! language a&&ear in this format4 SQL KEYWORD . S ! 1eywords are not casesensiti%e and may #e written in any letter case, #ut the training guide uses u&&ercase.

    3laceholders for user in&ut inside a&&earing inside com&uter in&ut a&&ear in this format4 ; user input>

    2or em&hasis, the folowing style is used4 Emphasis

    2or e9tra em&hasis, the following style is used4 Extra Emphasis

    indicates a command that youe9ecute from your shell, and mysql> indicates a statement that you e9ecute from the mysql client &rogram4

    shell> mysql -u root -h 127.0.0.1

    mysql> SELECT * FROM world.City;

    The 7shell8 is your command inter&reter. 6n !inu9, this is ty&ically a &rogram such as sh , csh , or bash . 6n

  • 8/10/2019 D61762GC10_TOC_sg5

    5/20

    MySQL for Database Administrators Preface

    $n elli&sis - ... indicates the omission of a section of a statement, ty&ically to &ro%ide a shorter %ersion of morecom&le9 synta9. 2or e9am&le, INSERT ... SELECT is shorthand for the form of INSERT statement that isfollowed #y a SELECT statement.

    $n elli&sis can also indicate that the &receding synta9 element of a statement may #e re&eated. In the followinge9am&le, multi&le reset=o&tion %alues may #e gi%en, with each of those after the first &receded #y commas4

    RESET reset_option ' reset_option ! ...

    )ommands for setting shell %aria#les are shown using >ourne shell synta9. 2or e9am&le, the sequence to set the ))en%ironment %aria#le and run the configure command loo1s li1e this in >ourne shell synta94

    shell> CC()cc . con+i)ure

    If you are using csh or tcsh , you must issue commands somewhat differently4

    shell> seten, CC )cc

    and

    shell> . con+i)ure

    %

  • 8/10/2019 D61762GC10_TOC_sg5

    6/20

    MySQL for Database Administrators Preface

    S$//ortin& ima&es $sed in t.is !rainin& ($ide

    The following is a summary of the standard images used in this manual to su&&ort the instruction4

    )MA(E AME DES-R)P!)0

    3re&aration This image is used to descri#e the ste&s required to #e com&leted &rior to &erforming a hands+on e9ercise.

  • 8/10/2019 D61762GC10_TOC_sg5

    7/20

    MySQL for Database Administrators Preface

    A%+no1*ed&ments

    Sun Microsystems would li1e to than1 the many indi%iduals that &layed a &art in #ringing this training material tothe numerous students who will #enefit from the 1nowledge and effort that each of these contri#utors &ut into the

    training. *%en though there were a large num#er of contri#utions from many Sun Microsystems? em&loyees, thefollowing list of contri#utors &layed a %ital role in de%elo&ing this material and ensuring that its contents wereaccurate, timely and most of all &resented in a way that would #enefit those that are utili@ing it for the #enefit ofim&ro%ing their s1ills with MyS !.

    Ma2 Met.er , )ourse "e%elo&ment Manager

    Sara. S/roe.n*e , !ead Instructor, Su#Aect Matter *9&ert

    Steven 3ones , Su#Aect Matter *9&ert

    (*ynn D$r.am , Su#Aect Matter *9&ert

    3effrey (orton , Instructional "esigner and *ditor

    %ii

  • 8/10/2019 D61762GC10_TOC_sg5

    8/20

  • 8/10/2019 D61762GC10_TOC_sg5

    9/20

    MySQL for Database Administrators Preface

    -o$rse 0b4e%tives

    This instructor led, hands+on class will teach you how to &ro&erly install MyS !, create and e9ecute #ac1u&strategies, secure users &ri%ileges, set resource limitations, and access controls. In addition, this course will &re&are

    students for the MyS ! "ata#ase $dministrators certification e9am. "escri#e the MyS ! $rchitecture

    Install MyS !

    B&grade to MyS ! '.(

    3erform the MyS ! start and shutdown o&erations

    )onfigure MyS ! ser%er o&tions at runtime

    $cti%ate and manage numerous ser%er logs

    3erform common ">$ tas1s utili@ing MyS ! &rograms

    Bse I 26 M$TI6 =S)C*M$ to access metadata

    *%aluate data ty&es and character sets

    Bnderstand data loc1ing in MyS !

    Bnderstand the multi&le storage engines a%aila#le in MyS !

    Maintain and Manage MyS ! ta#les

    3erform #ac1u& and restore o&erations

    Manage user maintenance and security

    Maintain integrity of a MyS ! installation

    Bnderstand the ">$?s role concerning stored routines

    Btili@e triggers for administration tas1s

    Bnderstand %iews

    )om&are multi&le en%ironment o&tions

    Derifying the security of the ser%er

    Bnderstand ta#le &artitioning

    Set u& and schedule e%ents for maintenance

    "escri#e introductory &erformance tuning techniques

    "escri#e introductory high a%aila#ility techniques

    9i

    5

    6

  • 8/10/2019 D61762GC10_TOC_sg5

    10/20

  • 8/10/2019 D61762GC10_TOC_sg5

    11/20

    MySQL for Database Administrators Preface

    Table of Contents

    1 Introduction............................................................................................................................... 1-0

    1.1 Learning Objectives...........................................................................................................1-11.2 MySQL Overview..............................................................................................................1-21.2.1 Sun Acquisition.......................................................................................................... 1-21.2.2 MySQL Partners.........................................................................................................1-3

    1.3 MySQL Products............................................................................................................... 1-41.3.1 MySQL Database Products........................................................................................ 1-41.3.2 MySQL GUI Tools..................................................................................................... 1-41.3.3 Other MySQL Tools................................................................................................... 1-51.3.4 MySQL Connectors....................................................................................................1-51.3.5 Solutions for Embedding MySQL............................................................................. 1-6

    1.4 MySQL Services................................................................................................................ 1-71.4.1 MySQL Training........................................................................................................ 1-71.4.2 MySQL Certification.................................................................................................. 1-71.4.3 MySQL Consulting.................................................................................................... 1-71.4.4 MySQL Support......................................................................................................... 1-7

    1.5 The MySQL Enterprise Subscription.................................................................................1-81.5.1 MySQL Enterprise Server..........................................................................................1-81.5.2 24x7 Production Support............................................................................................1-81.5.3 MySQL Enterprise Monitor....................................................................................... 1-91.5.4 Obtaining a MySQL Enterprise Subscription.......................................................... 1-10

    1.6 Supported Operating Systems.......................................................................................... 1-111.7 MySQL Certification Program.........................................................................................1-121.8 Training Curriculum Paths............................................................................................... 1-131.9 MySQL Website............................................................................................................... 1-17

    1.9.1 MySQL Community Web Page................................................................................ 1-181.9.2 MySQL Online Documentation............................................................................... 1-20

    1.10 Installing MySQL.......................................................................................................... 1-231.11 Installing the 'world' database........................................................................................ 1-241.12 Chapter Summary.......................................................................................................... 1-25

    2 MySQL Architecture................................................................................................................. 2-12.1 Learning Objectives...........................................................................................................2-22.2 Client/Server Architecture................................................................................................. 2-3

    2.2.1 MySQL Server .......................................................................................................... 2-32.2.2 Client Programs .........................................................................................................2-32.2.3 Communication Protocols..........................................................................................2-42.2.4 MySQL Non-Client Utilities ..................................................................................... 2-5

    2.3 MySQL Architecture Overview......................................................................................... 2-62.3.1 Core Shared Subsystems............................................................................................ 2-6

    2.3.2 Query Parsing, Optimization and Execution..............................................................2-82.3.3 Query Cache...............................................................................................................2-82.3.4 Storage Engine Implementation.................................................................................2-8

    2.4 How MySQL Uses Disk Space........................................................................................ 2-102.4.1 Data Directory..........................................................................................................2-10

    2.5 How MySQL Uses Memory............................................................................................ 2-132.5.1 Memory Allocation Categories................................................................................ 2-13

    9iii

  • 8/10/2019 D61762GC10_TOC_sg5

    12/20

  • 8/10/2019 D61762GC10_TOC_sg5

    13/20

    MySQL for Database Administrators Preface

    5.3 Invoking MySQL Client Programs.................................................................................... 5-45.3.1 General Command Option Syntax ............................................................................ 5-45.3.2 Connection Parameter Options ................................................................................. 5-5

    5.4 Using the mysql client..................................................................................................... 5-105.4.1 Using mysql Interactively ....................................................................................... 5-105.4.2 Statement Terminators .............................................................................................5-115.4.3 The mysql Prompts ................................................................................................. 5-135.4.4 Using Editing Keys in mysql .................................................................................. 5-135.4.5 Using script files with mysql....................................................................................5-145.4.6 MySQL Output Formats ..........................................................................................5-155.4.7 Client Commands and SQL Statements .................................................................. 5-165.4.8 Using Server-Side Help ...........................................................................................5-175.4.9 Using the Safe Updates Option ............................................................................... 5-18

    5.5 The mysqladmin Client....................................................................................................5-225.6 MySQL Connectors......................................................................................................... 5-23

    5.6.1 Native (C).................................................................................................................5-235.6.2 MySQL Connector/ODBC ...................................................................................... 5-235.6.3 MySQL Connector/J ............................................................................................... 5-245.6.4 MySQL Connector/NET ......................................................................................... 5-245.6.5 PHP.......................................................................................................................... 5-24

    5.7 Third-Party APIs.............................................................................................................. 5-255.8 Chapter Summary............................................................................................................ 5-26

    6 Data Types................................................................................................................................. 6-16.1 Learning Objectives...........................................................................................................6-26.2 Data Type Overview.......................................................................................................... 6-3

    6.2.1 The ABCs of Data Types..........................................................................................6-36.2.2 Creating Tables with Data Types................................................................................6-3

    6.3 Numeric Data Types.......................................................................................................... 6-46.3.1 Integer Types.............................................................................................................. 6-4

    6.3.2 Floating-Point Types................................................................................................. 6-56.3.3 Fixed-Point Types...................................................................................................... 6-76.3.4 BIT Types................................................................................................................... 6-8

    6.4 Character String Data Types........................................................................................... 6-156.4.1 Unstructured Character String Data Types..............................................................6-166.4.2 Text Type Comparison............................................................................................ 6-186.4.3 Structured Character String types............................................................................ 6-196.4.4 Character Set and Collation Support........................................................................6-20

    6.5 Binary String Data Types................................................................................................6-286.5.1 Binary Types........................................................................................................... 6-286.5.2 Binary String Type Comparison...............................................................................6-29

    6.6 Temporal Data Types....................................................................................................... 6-306.6.1 Temporal Data Types................................................................................................6-30

    6.7 NULLs............................................................................................................................. 6-366.7.1 The Meaning of NULL............................................................................................ 6-366.7.2 When to Use NULL................................................................................................ 6-366.7.3 When NOT to Use NULL........................................................................................ 6-37

    6.8 Column Attributes............................................................................................................6-386.8.1 Using the AUTO_INCREMENT Column Attribute................................................ 6-40

    9%

  • 8/10/2019 D61762GC10_TOC_sg5

    14/20

    MySQL for Database Administrators Preface

    6.8.2 Choosing Data Types for Character Columns.......................................................... 6-446.9 Chapter Summary............................................................................................................ 6-48

    7 Obtaining Metadata................................................................................................................... 7-17.1 Learning Objectives...........................................................................................................7-27.2 Metadata Access Methods................................................................................................. 7-37.3 The INFORMATION_SCHEMA database........................................................................7-4

    7.3.1 INFORMATION_SCHEMA Tables.......................................................................... 7-57.3.2 Displaying INFORMATION_SCHEMA Tables........................................................ 7-6

    7.4 Using SHOW and DESCRIBE ....................................................................................... 7-137.4.1 SHOW Statements................................................................................................... 7-137.4.2 DESCRIBE Statements............................................................................................7-18

    7.5 The mysqlshow Client Program.......................................................................................7-227.6 Administration Tasks with INFORMATION_SCHEMA................................................ 7-277.7 Chapter Summary............................................................................................................ 7-29

    8 Storage Engines......................................................................................................................... 8-18.1 Learning Objectives...........................................................................................................8-28.2 SQL Parser and Storage Engine Tiers................................................................................8-3

    8.2.1 Storage Engine Breakdown ....................................................................................... 8-38.3 Storage Engines and MySQL............................................................................................ 8-5

    8.3.1 Available Storage Engines..........................................................................................8-58.3.2 The Most Common Storage Engines......................................................................... 8-58.3.3 View Available Storage Engines................................................................................ 8-68.3.4 Setting the Storage Engine......................................................................................... 8-68.3.5 Displaying Storage Engine Information.....................................................................8-7

    8.4 The MyISAM Storage Engine......................................................................................... 8-108.4.1 MyISAM Row Storage Formats.............................................................................. 8-108.4.2 Compressing MyISAM Tables................................................................................. 8-118.4.3 MyISAM Locking....................................................................................................8-138.4.4 MyISAM Pros and Cons.......................................................................................... 8-14

    8.5 The InnoDB Storage Engine............................................................................................8-178.5.1 The InnoDB Tablespace and Logs........................................................................... 8-178.5.2 The InnoDB Plugin.................................................................................................. 8-198.5.3 The InnoDB Log files and Buffers........................................................................... 8-268.5.4 InnoDB Locking.......................................................................................................8-278.5.5 InnoDB Pros and Cons.............................................................................................8-30

    8.6 The MEMORY Storage Engine....................................................................................... 8-318.6.1 MEMORY Indexing Options................................................................................... 8-318.6.2 MEMORY Best Practices.........................................................................................8-328.6.3 MEMORY Pros and Cons........................................................................................ 8-32

    8.7 Storage Engine Summary................................................................................................ 8-348.8 Other Storage Engines..................................................................................................... 8-35

    8.8.1 The EXAMPLE Storage Engine.............................................................................. 8-35

    8.8.2 The ARCHIVE Storage Engine............................................................................... 8-358.8.3 The CSV Storage Engine......................................................................................... 8-368.8.4 The BLACKHOLE Storage Engine.........................................................................8-378.8.5 The NDB Storage Engine (MySQL Cluster)........................................................... 8-398.8.6 Falcon ......................................................................................................................8-40

    8.9 Choosing Appropriate Storage Engines........................................................................... 8-41

    9%i

  • 8/10/2019 D61762GC10_TOC_sg5

    15/20

    MySQL for Database Administrators Preface

    8.10 Using Multiple Storage Engines.................................................................................... 8-428.11 Storage engine comparison chart................................................................................... 8-438.12 Chapter Summary.......................................................................................................... 8-46

    9 Partitioning................................................................................................................................ 9-19.1 Learning Objectives...........................................................................................................9-29.2 Overview of Partitioning................................................................................................... 9-3

    9.2.1 MySQL Specific Partitioning .................................................................................... 9-49.3 Reasons for Using Partitioning.......................................................................................... 9-59.4 Creating a Partitioned Table...............................................................................................9-7

    9.4.1 Basic Partition Syntax................................................................................................ 9-79.4.2 RANGE Partitioning.................................................................................................. 9-79.4.3 LIST Partitioning....................................................................................................... 9-89.4.4 HASH Partitioning..................................................................................................... 9-99.4.5 KEY Partitioning...................................................................................................... 9-109.4.6 Subpartitioning.........................................................................................................9-10

    9.5 Obtaining Partition Information.......................................................................................9-129.5.1 SHOW CREATE TABLE........................................................................................ 9-129.5.2 SHOW TABLE STATUS......................................................................................... 9-129.5.3 INFORMATION_SCHEMA Metadata.................................................................... 9-139.5.4 EXPLAIN PARTITIONS......................................................................................... 9-14

    9.6 Modifying Partitions........................................................................................................ 9-159.6.1 Altering a Partition................................................................................................... 9-159.6.2 Using the COALESCE PARTITION statement.......................................................9-179.6.3 Redefine Partitioning Type....................................................................................... 9-17

    9.7 Removing Partitions........................................................................................................ 9-189.7.1 Dropping Partitions.................................................................................................. 9-189.7.2 Removing all partitions............................................................................................ 9-19

    9.8 Partition Modification Performance Effects.................................................................... 9-209.9 Partition Pruning.............................................................................................................. 9-21

    9.10 Storage Engine Partitioning Information....................................................................... 9-229.10.1 Partitioning with MyISAM.................................................................................... 9-239.10.2 Partitioning with InnoDB.......................................................................................9-24

    9.11 Partitioning and Locking ...............................................................................................9-249.12 Partitioning Limitations................................................................................................. 9-259.13 Chapter Summary.......................................................................................................... 9-28

    10 Transactions And Locking..................................................................................................... 10-110.1 Learning Objectives.......................................................................................................10-210.2 What is a Transaction?................................................................................................... 10-3

    10.2.1 ACID...................................................................................................................... 10-410.3 Transaction Control Statements..................................................................................... 10-5

    10.3.1 The autocommit mode............................................................................................10-510.3.2 Statements causing an Implicit COMMIT............................................................. 10-7

    10.3.3 Finding a Storage Engine that supports transactions............................................. 10-710.4 Isolation Levels............................................................................................................10-1310.4.1 Consistency issues................................................................................................10-1310.4.2 Four Levels...........................................................................................................10-14

    10.5 Locking........................................................................................................................ 10-1910.5.1 Locking Concepts.................................................................................................10-19

    9%ii

  • 8/10/2019 D61762GC10_TOC_sg5

    16/20

    MySQL for Database Administrators Preface

    10.5.2 Locking Reads......................................................................................................10-1910.5.3 Implicit Locks...................................................................................................... 10-23

    10.6 Chapter Summary........................................................................................................ 10-2611 Security and User Management............................................................................................. 11-1

    11.1 Learning Objectives....................................................................................................... 11-211.2 Security Risks.................................................................................................................11-311.3 Security Measures.......................................................................................................... 11-4

    11.3.1 Network Security....................................................................................................11-411.3.2 Operating System Security..................................................................................... 11-511.3.3 Filesystem Security................................................................................................ 11-511.3.4 MySQL Server User Security.................................................................................11-6

    11.4 Privileges........................................................................................................................11-711.4.1 Types of Privileges MySQL Supports.................................................................... 11-711.4.2 The Grant Tables.................................................................................................... 11-911.4.3 Modifying Grant Tables........................................................................................11-1111.4.4 The GRANT Statement........................................................................................ 11-1111.4.5 The SHOW GRANTS Statement......................................................................... 11-12

    11.5 User Accounts.............................................................................................................. 11-1311.5.1 Creating and Dropping User Accounts.................................................................11-1411.5.2 Specifying Account Names.................................................................................. 11-1511.5.3 Setting Account Password.................................................................................... 11-16

    11.6 User Account Maintenance.......................................................................................... 11-1911.6.1 Revoking Privileges............................................................................................. 11-1911.6.2 When Privilege Changes Take Effect................................................................... 11-2111.6.3 Specifying Resource Limits................................................................................. 11-2111.6.4 Precautions for Granting Privileges..................................................................... 11-25

    11.7 Disabling Client Access Control.................................................................................. 11-2611.8 Using Secure Connections........................................................................................... 11-27

    11.8.1 Using SSL.............................................................................................................11-27

    11.9 Chapter Summary.........................................................................................................11-3312 Table Maintenance................................................................................................................. 12-112.1 Learning Objectives.......................................................................................................12-212.2 Table Maintenance......................................................................................................... 12-3

    12.2.1 SQL Statements for Table Maintenance Operations ............................................. 12-312.2.2 The CHECK TABLE statement............................................................................. 12-412.2.3 The CHECKSUM TABLE statement.....................................................................12-412.2.4 The REPAIR TABLES statement...........................................................................12-512.2.5 The ANALYZE TABLE statement........................................................................ 12-512.2.6 The OPTIMIZE TABLE statement........................................................................ 12-6

    12.3 Client and Utility Programs for Table Maintenance.................................................... 12-1012.3.1 The mysqlcheck Client Program.......................................................................... 12-1012.3.2 The myisamchk Utility......................................................................................... 12-11

    12.3.3 Options for mysqlchk and myisamchk.................................................................12-1212.4 Table Maintenance per Storage Engine....................................................................... 12-1612.4.1 InnoDB Table Maintenance................................................................................. 12-1712.4.2 MEMORY Table Maintenance.............................................................................12-1712.4.3 MyISAM Table Maintenance............................................................................... 12-1812.4.4 CSV Table Maintenance.......................................................................................12-19

    9%iii

  • 8/10/2019 D61762GC10_TOC_sg5

    17/20

    MySQL for Database Administrators Preface

    12.4.5 Archive Table Maintenance..................................................................................12-1912.5 Chapter Summary........................................................................................................ 12-22

    13 Exporting and Importing Data...............................................................................................13-113.1 Learning Objectives.......................................................................................................13-213.2 Exporting and Importing Data....................................................................................... 13-3

    13.2.1 Export Data Using SELECT with INTO OUTFILE.............................................. 13-313.2.2 Importing Data Using LOAD DATA INFILE........................................................13-9

    13.3 Import Data with SQL Scripts..................................................................................... 13-1313.4 Chapter Summary........................................................................................................ 13-15

    14 Programming with MySQL................................................................................................... 14-114.1 Learning Objectives.......................................................................................................14-214.2 What is a Stored Routine?..............................................................................................14-314.3 Execute Stored Routines................................................................................................14-514.4 Examine Stored Routines...............................................................................................14-614.5 Stored Routines and Execution Security....................................................................... 14-714.6 What are Triggers?......................................................................................................... 14-814.7 Creating Triggers........................................................................................................... 14-9

    14.7.1 Triggers Events.......................................................................................................14-914.7.2 Trigger Error Handling.........................................................................................14-12

    14.8 Delete Triggers.............................................................................................................14-1314.9 Restrictions on Triggers............................................................................................... 14-1314.10 Trigger Privileges.......................................................................................................14-1314.11 Events.........................................................................................................................14-18

    14.11.1 Schedule............................................................................................................. 14-2014.11.2 Event Scheduler and MySQL Privileges............................................................ 14-21

    14.12 DBA's Using MySQL's Programming Capabilities...................................................14-2714.12.1 Using stored routines and triggers for security purposes................................... 14-2714.12.2 Using Stored Routines to Enhance Performance............................................... 14-28

    14.13 Chapter Summary...................................................................................................... 14-33

    15 Views..................................................................................................................................... 15-115.1 Learning Objectives.......................................................................................................15-215.2 What Are Views?........................................................................................................... 15-315.3 Creating Views...............................................................................................................15-5

    15.3.1 The CREATE VIEW Statement............................................................................. 15-515.4 Updatable Views............................................................................................................ 15-8

    15.4.1 Insertable Views................................................................................................... 15-1015.4.2 SQL SECURITY and DEFINER Characteristics................................................ 15-1315.4.3 WITH CHECK OPTION..................................................................................... 15-14

    15.5 Managing Views.......................................................................................................... 15-1615.5.1 Checking Views................................................................................................... 15-1615.5.2 Altering Views...................................................................................................... 15-1715.5.3 Dropping Views................................................................................................... 15-17

    15.6 Obtaining View Metadata............................................................................................ 15-1915.6.1 Using the information_schema............................................................................ 15-1915.6.2 SHOW Statements............................................................................................... 15-20

    15.7 Chapter Summary........................................................................................................ 15-2316 Backup and Recovery............................................................................................................16-1

    16.1 Learning Objectives.......................................................................................................16-2

    9i9

  • 8/10/2019 D61762GC10_TOC_sg5

    18/20

    MySQL for Database Administrators Preface

    16.2 Backup Basics................................................................................................................16-316.2.1 Backup Types......................................................................................................... 16-416.2.2 Backup Strategy..................................................................................................... 16-5

    16.3 Backups with MySQL................................................................................................... 16-716.3.1 Logical (Textual) Backups..................................................................................... 16-716.3.2 Raw (Binary) Backups........................................................................................... 16-816.3.3 Snapshot-Based Backup......................................................................................... 16-816.3.4 Replication-Based Backup..................................................................................... 16-816.3.5 Binary Logging and Incremental Backup.............................................................. 16-9

    16.4 Backup Tools Overview...............................................................................................16-1016.4.1 Tool Impact on Database and Application Availability........................................16-11

    16.5 Making Raw Backups..................................................................................................16-1216.5.1 Making Raw MyISAM Backups..........................................................................16-1216.5.2 Making Raw InnoDB Backups............................................................................ 16-1316.5.3 Other Raw Backup Tools..................................................................................... 16-14

    16.6 Making Logical (Text) Backups.................................................................................. 16-1716.6.1 Making Logical Backups with mysqldump......................................................... 16-1716.6.2 Backing Up Stored Routines................................................................................ 16-20

    16.7 Backing Up Log and Status Files................................................................................ 16-2216.8 Replication as an Aid to Backup..................................................................................16-2316.9 Backup Methods Compared.........................................................................................16-2416.10 Data Recovery............................................................................................................16-25

    16.10.1 Data Importing Methods Used for Recovery..................................................... 16-2516.11 Processing Binary Log Contests................................................................................ 16-2816.12 Chapter Summary...................................................................................................... 16-30

    17 Introduction toPerformance Tuning................................................................................................................... 17-1

    17.1 Learning Objectives.......................................................................................................17-217.2 Using EXPLAIN to Analyze Queries............................................................................ 17-3

    17.2.1 How EXPLAIN Works...........................................................................................17-317.2.2 Nested Joins........................................................................................................... 17-517.2.3 Analyzing a Nested Join.........................................................................................17-6

    17.3 General Table Optimizations......................................................................................... 17-817.4 Setting and Interpreting MySQL Server Variables...................................................... 17-11

    17.4.1 Setting Server Variables....................................................................................... 17-1117.4.2 Accessing Server Variable Information................................................................17-1217.4.3 Accessing Status Variable Information................................................................ 17-1417.4.4 Obtaining Metadata for Server Variables............................................................. 17-17

    17.5 Chapter Summary........................................................................................................ 17-1918 Introduction to MySQLHigh Availability.........................................................................................................................18-1

    18.1 Learning Objectives.......................................................................................................18-2

    18.2 MySQL Replication....................................................................................................... 18-318.2.1 MySQL Replication Threads and Files.................................................................. 18-418.2.2 Setting up MySQL Replication.............................................................................. 18-518.2.3 Backing Up a Slave................................................................................................18-918.2.4 Monitoring MySQL Replication.......................................................................... 18-1018.2.5 Slave I/O Thread States........................................................................................ 18-11

    99

  • 8/10/2019 D61762GC10_TOC_sg5

    19/20

    MySQL for Database Administrators Preface

    18.2.6 Slave SQL Thread States......................................................................................18-1218.2.7 Replication and the Binary Log........................................................................... 18-13

    18.3 Chapter Summary........................................................................................................ 18-2719 Conclusion............................................................................................................................. 19-1

    19.1 Learning Objectives.......................................................................................................19-219.2 Training and Certification Website............................................................................... 19-319.3 Course Evaluation..........................................................................................................19-519.4 Thank you!..................................................................................................................... 19-519.5 Q&A Session..................................................................................................................19-6

    Appendix A MySQL Lab Preparation....................................................................................... A-1Appendix B Further Practice and Quiz Solutions......................................................................B-1Appendix C Explain Output Columns....................................................................................... C-1Appendix D MySQL Enterprise Monitor.................................................................................. D-1

    99i

  • 8/10/2019 D61762GC10_TOC_sg5

    20/20