MySQL for Developers II — A 3-Day Course
Course Synopsis
This course is designed for MySQL Developers who have a basic understanding of a MySQL database and SQL commands. The course provides further practical experience in more advanced MySQL commands and SQL statements including Stored Routines, Triggers and Events.
Course Objectives
By the end of the course, delegates will be able to:
- Use User Variable Syntax and Properties
- Import and export data from within MySQL
- Import and export data from the command line
- Perform complex joins to access multiple tables
- Perform complex subqueries
- Create, manage and use views
- Use prepared statements
- Create and use stored routines
- Create and use triggers
- Create and use events
- Obtain database metadata
- Optimize queries
- use The Event Scheduler
- Work with the main storage engines
- Debug MySQL applications
Suitable For
- MySQL Developers who have an understanding of a MySQL database and SQL commands as covered on the Introduction to MySQL course and the MySQL for Developers I course.
Course Prerequisities
A good working knowledge of MySQL is required. This can be gained by attendance on the Introduction to MySQL course and the MySQL for Developers I course.
Publicly scheduled dates, locations, and prices
London — £895 (+VAT)
- 17–19 Mar 2010
- 12–14 May 2010
- 14–16 Jul 2010
- 25–27 Aug 2010
- 20–22 Oct 2010
- 15–17 Dec 2010
Manchester — £895 (+VAT)
- 9–11 Jun 2010
- 11–13 Aug 2010
- 13–15 Oct 2010
- 22–24 Dec 2010
Contents
Obtaining Database Metadata
- What is metadata?
- The mysqlshow utility
- The show and describe commands
- Describing tables
- The information_schema
- Listing tables
- Listing columns
- Listing views
- Listing key_columns_usage
- Exercises: Obtaining database metadata
Debugging
- MySQL error messages
- The show statement
- Show errors
- Show count(*) errors
- Show warnings
- Show count(*) warnings
- Note messages
- The perror utility
- Exercises: Debugging
Joins
- Overview of inner joins
- Cartesian product
- Inner joins with original syntax
- Join with additional condition
- Non equi-join
- Using table aliases to avoid name clashes
- Inner Joins With ISO/ANSI Syntax
- Natural join
- Join using
- Join on
- Non equi-join
- Outer Joins
- Left outer joins
- Right outer joins
- Full outer joins
- Multiple table update
- Updating multiple tables simultaneously
- Updating rows in one table based on a condition in another
- Updating rows in one table reading data from another
- Multiple table delete
- Deleting from multiple tables simultaneously
- Deleting rows in one table based on a condition in another
- Exercises: Coding joins
Subqueries
- Types of subquery
- Multiple-column subqueries
- Correlated subqueries
- Using the ANY, ALL and SOME operators
- Using the EXISTS operator
- Subqueries as scalar expressions
- Inline views
- Converting subqueries to joins
- Using subqueries in updates and deletes
- Exercises: Coding subqueries
Views
- Why views are used
- Creating views
- Column names
- View creation restrictions
- View algorithms
- Merge
- Updateable views
- Altering and dropping views
- Altering views
- Dropping views
- Displaying information about views
- Describe and show columns
- Show table status
- Show tables
- Show full tables
- Information_schema
- Privileges for views
- Exercises: Using views
Import and Export
- Exporting using SQL
- Data file location
- Privileges required to export data
- Format of the data file
- Importing using SQL
- Data file location
- Specifying the format
- Ignoring lines
- Missing columns
- Skipping and transforming
- Processing duplicates
- Messages when loading data
- Privileges required to load data
- Exporting from the command line
- Mysqldump main options
- Importing from the command line
- Mysqlimport main options
- Exercises: Importing and exporting
User Variables and Prepared Statements
- User variables
- Set
- User variables in a select
- Prepared statements
- The prepare statement
- The execute statement
- The deallocate statement
- Exercises: Using variables and prepared statements
Introduction to Stored Routines
- Types of stored routines
- Benefits of stored routines
- Stored routine features
- Differences between procedures and functions
- Stored routines namespace
- Blocks
- The delimiter statement
- Declaring variables and constants
- Assignment
- Definer rights and invoker rights
- SELECT INTO
- Stored routine maintenance
- Altering stored routines
- Dropping stored routines
- Obtaining stored routine metadata
- Stored routine privileges and execution security
- Exercises: Writing simple stored routines
Stored Routines - Program Logic
- Conditional execution statements
- The IF .. THEN .. ELSEIF construct
- The CASE statement
- Loops
- The basic loop
- The while loop
- The repeat loop
- The iterate statement
- Nested loops
- Exercises: Writing stored routines with program logic
Stored Routines - Exception Handlers & Cursors
- Exception handlers
- Cursors
- What is a cursor?
- Cursor operations
- Declaring cursors
- Opening and closing cursors
- Fetching rows
- Status checking
- Exercises: Writing stored routines with program logic
Procedures with Parameters
- The create procedure statement
- Parameters
- Parameter Modes
- Calling Procedures With Parameters
- Exercises: Writing stored routines with parameters
Functions
- What is a function?
- The create function statement
- Executing functions
- Executing functions from code
- Executing functions from SQL statements
- The deterministic and sql clauses
- Exercises: Writing functions
Triggers
- Trigger creation
- Restrictions on triggers
- The create trigger statement
- The associated table
- The triggering event
- Trigger timing
- The trigger type
- Using the old and new qualifiers
- Managing triggers
- Destroying triggers
- Required privileges
- Exercises: Writing triggers
The Event Scheduler
- Event scheduler concepts
- Event scheduler configuration
- Creating, altering and dropping events
- Event scheduler monitoring
- Events and privileges
- Exercises: Creating and using events
Basic Optimisation
- Normalisation
- Insert, update, delete problems
- First normal form
- Second normal form
- Third normal form
- Using indexes for optimization
- Indexing principles
- Prefixed indexes
- Composite indexes
- Unintentional full table scans
- Index only searches
- General query enhancement
- Limit
- Summary tables
- Explain
- Choosing an appropriate storage enginge
- Innodb
- Some design points concerning innodb
- MYISAM
- Some design points concerning MYISAM
- Exercises: Making use of basic optimizations
More About Indexes
- Indexes and joins
- Exercises: Investigating indexes and joins
