MySQL in a Nutshell [0]
Russell Dyer
Editor
Andy Oram
Copyright © 2009 Russell Dyer
O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://safari.oreilly.com). For more information, contact our corporate/institutional sales department: (800) 998-9938 or corporate@oreilly.com.
Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of O’Reilly Media, Inc. MySQL in a Nutshell, the image of a pied kingfisher, and related trade dress are trademarks of O’Reilly Media, Inc.
Many of the designations uses by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and O’Reilly Media, Inc. was aware of a trademark claim, the designations have been printed in caps or initial caps.
While every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein.
O'Reilly Media
* * *
Dedication
To my friend Richard Stringer, for encouraging me in literature, liberalism, and writing, and for helping me to become the person I was meant to be.
Preface
MySQL is the most popular open source database system available. Although it’s free, it’s still very dependable and fast, and is being employed increasingly in areas that used to be the province of Oracle or MS SQL Server. Thanks to a variety of utilities packaged with MySQL, administration is fairly effortless. With its several application programming interfaces (APIs), it’s easy to develop your own software to interface with MySQL.
This book provides a quick reference to MySQL statements and functions, the administrative utilities, and the most popular APIs. The first few chapters are designed to help you to get started with MySQL. Each chapter on an API also starts with a tutorial.
When this book was written, version 5.0 of MySQL was generally available, and early releases of the development versions of 5.1 and 6.0 were available but not yet stable. As a result, you will find mostly features from version 5.0.x in this book. Features that appear only in newer versions are noted as such.
The Purpose of This Book
The purpose of this book is to provide a quick reference to:
MySQL statements and functions
Command-line options and configuration information for the MySQL server and utilities
The most popular APIs used to access MySQL databases
Several chapters start with tutorials, but the central purpose of the book is to fill in the gaps for people who are already comfortable with relational databases.
The format that I’ve followed for a description of each statement or function is to move from curt memory-joggers to more leisurely explanations. If you know the statement or function that you’re looking up, but can’t quite remember the syntax, you’ll find that first. If you need a bit more information to jog your memory or to clarify the possibilities available, you can find this in the first sentence or so of the explanation. If you require more clarification, you can continue with the slower-paced material that will follow a statement or function. Examples of usage are provided for almost all statements and functions.
In summary, the goal is to be brief but fairly complete, and to increase the level of detail as you read on.
How This Book Is Organized
This book is broken up into 14 chapters and 3 appendixes, as follows.
Part I, Introduction and Tutorials
Chapter 1, Introduction to MySQL, explains the major components of MySQL and useful guidelines for other information on MySQL.
Chapter 2, Installing MySQL, describes how to get MySQL running on common operating systems supported by MySQL AB. It is necessary to read this chapter only if your system does not already have MySQL installed.
Chapter 3, MySQL Basics, introduces SQL (Structured Query Language) and use of the mysql command-line interface. It’s