O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required


Book Description

The MySQL Phrasebook is a pocket guide that is jam-packed with useful and essential code "phrases" for the MySQL developer's everyday use. Packed with practical solutions for tasks that the MySQL developer must accomplish every day, it fills the need for a short, functional, to-the-point reference for MySQL. This is the guide to consult when you need an immediate, applicable solution to frequent tasks and code that is flexible and adaptable to your needs. Your time won't be wasted on more tutorials — it simply puts essential "phrases" at your fingertips that you can take with you everywhere.

Table of Contents

  1. MySQL® Phrasebook
    1. About the Authors
    2. Acknowledgments
    3. We Want to Hear from You!
    4. Introduction
      1. Omissions: What This Book Doesn’t Cover
      2. Conventions Used in This Book
        1. Default Assumptions
        2. shell>
        3. mysql>
      3. The MySQL Phrasebook Website
    5. 1. Maps of MySQL
        1. The MySQL RDBMS
        2. The LAMP Platform
        3. MySQL Table Terminology
        4. Sample Tables
    6. 2. Creating and Managing Databases, Tables, and Indexes
        1. Quick Guide: Databases, Tables, Columns, and Indexes
          1. A Simple Table Metaphor
        2. Creating and Managing Databases
          1. List All Databases
          2. Get a Filtered List of Databases
          3. Setting the Default Database
          4. Creating a Database
          5. Deleting a Database
        3. Creating and Managing Tables
          1. Listing Some or All Tables in a Database
          2. Creating Tables
          3. Renaming Tables
          4. Deleting Tables
          5. Copying Tables
        4. Creating and Managing Columns
          1. Adding Columns
          2. Changing Column Definitions (and Names)
          3. Deleting Columns
          4. Identifiers
        5. Creating and Managing Indexes
          1. Adding an Index to a Table
          2. Renaming an Index
          3. Deleting an Index
        6. See Also
    7. 3. Storing Data
        1. Adding Data to a Table
        2. Adding Many Rows in One Query Using INSERT
        3. Assigning Unique Row Numbers with auto_increment
        4. Inserting the Current Date and Time (Using a MySQL Function)
        5. Loading SQL Commands from a File
        6. Inserting Data from Another Table
        7. Importing Data from Text Files
        8. Inserting Data Rapidly
        9. See Also
    8. 4. Retrieving Data: Simple Queries
        1. Limiting the Number of Rows Returned
        2. Sorting Result Sets
        3. Ignoring Duplicate Rows
        4. Finding Text That Matches a Pattern
        5. Finding the Smallest, Largest, or Average Value in a Column
        6. Date and Time Manipulation
        7. Storing Exact Floating Point Numbers
        8. Dealing with NULL
        9. Sending Query Results to a File
        10. Writing a BLOB to a File
    9. 5. Manipulating Data
        1. Safety Tips
        2. Testing Queries Inside of a Transaction
        3. An Overview of Updating Column Values
        4. Updating Columns with Formulas
        5. Deleting Rows
        6. Deleting Rows from Multiple Tables
        7. See Also
    10. 6. User Management and Security
        1. Creating Users
        2. Deleting Users
        3. Renaming a User
        4. Using Wildcards
        5. Finding Users of a Given Database or Table
        6. Setting Passwords
        7. Tailoring User Permissions
        8. Allowing Other Users to Grant Privileges
        9. Viewing a User’s Privileges
        10. Removing User Access
        11. Disabling Network Access
        12. Disabling User Authentication
        13. Using SSL-Secured Connection
        14. See Also
    11. 7. The mysql Command-line Client
        1. Connecting to a MySQL Server
        2. Using the Client in Batch Mode
        3. Basic mysql Command-line Client Navigation
        4. Erasing the Current Line or Query
        5. Setting Connection Defaults with an Option File
        6. Getting Help Within mysql
        7. Editing Complex Commands with a Text Editor
        8. Database, Table, and Column Name Completion
        9. Using the Command-line History
        10. Other Useful Tools
    12. 8. MySQL APIs
        1. The C Language API
          1. Connecting to MySQL
          2. Executing a Query
          3. Fetching Data from a Result Set
          4. Displaying Error Messages
          5. Closing a Connection
          6. A Sample C Program
        2. The Perl API
          1. Connecting to MySQL
          2. Executing a Query
          3. Fetching Data from a Result Set
          4. Displaying Error Messages
          5. Closing a Connection
          6. A Sample Perl Script
        3. The PHP API
          1. Connecting to MySQL
          2. Executing a Query
          3. Fetching Data from a Result Set
          4. Displaying Error Messages
          5. Closing a Connection
          6. A Sample PHP Script
        4. See Also
    13. 9. Advanced Queries
        1. Joins
          1. Joining Tables
          2. The JOIN Keyword
          3. Table Aliases
          4. Outer Joins
          5. Column Aliases
        2. Subqueries
          1. Filtering with a Subquery
          2. Selecting the Result of a Subquery
          3. Correlated Subqueries
        3. Combining Queries with UNION
        4. See Also
    14. 10. Troubleshooting and Emergencies
        1. Backing Up
          1. Taking a Full Backup
          2. Taking an Incremental Backup
        2. Restoring from a Backup
          1. Restoring a Full Backup
          2. Restoring an Incremental Backup
        3. Corrupted Table Data
        4. Server Crash
        5. Common Errors
          1. Can’t Connect to MySQL Server
          2. Access Denied
          3. Too Many Connections
          4. MySQL Server Has Gone Away
          5. Got Error from Table Handler
        6. Getting Help
    15. A. A Brief MySQL Tutorial
        1. Getting Started
        2. Creating a Database
          1. Showing Existing Databases
          2. Running the CREATE DATABASE Command
        3. Creating Tables
          1. Designing Tables
          2. Jumping Right In
          3. Designing Your First Table
            1. Choosing a Primary Key
            2. Defining Columns
          4. Naming Columns
          5. Creating the book Table
          6. Creating the person Table
          7. Creating the loan Table
        4. Populating Tables with Data
        5. Exploring Table Creation
        6. Adding Indexes to Existing Tables
        7. Finding Information About Tables
        8. Creating Users
          1. Creating a User
        1. Summary