mysql 5.0 reference manual - school of computingamay/mafia/refman-5.0-en.pdf · overview of the...

1941
MySQL 5.0 Reference Manual

Upload: lexuyen

Post on 06-Jul-2018

224 views

Category:

Documents


0 download

TRANSCRIPT

  • MySQL 5.0 Reference Manual

  • MySQL 5.0 Reference Manual

    Abstract

    This is the MySQL Reference Manual. It documents MySQL 5.0 through 5.0.24.

    Document generated on: 2006-07-28 (revision: 2875)

    Copyright 1997-2006 MySQL AB

    This documentation is NOT distributed under a GPL license. Use of this documentation is subject to the following terms: You maycreate a printed copy of this documentation solely for your own personal use. Conversion to other formats is allowed as long as theactual content is not altered or edited in any way. You shall not publish or distribute this documentation in any form or on any me-dia, except if you distribute the documentation in a manner similar to how MySQL disseminates it (that is, electronically for down-load on a website with the software) or on a CD-ROM or similar medium, provided however that the documentation is dissemin-ated together with the software on the same medium. Any other use, such as any dissemination of printed copies or use of this doc-umentation, in whole or in part, in another publication, requires the prior written consent from an authorized representative ofMySQL AB. MySQL AB reserves any and all rights to this documentation not expressly granted above.

    Please email for more information or if you are interested in doing a translation.

  • Table of ContentsPreface .................................................................................................................. xxii1. General Information ................................................................................................. 1

    1.1. About This Manual ........................................................................................ 11.2. Conventions Used in This Manual .................................................................... 21.3. Overview of MySQL AB ................................................................................ 41.4. Overview of the MySQL Database Management System ...................................... 5

    1.4.1. History of MySQL .............................................................................. 61.4.2. The Main Features of MySQL ............................................................... 61.4.3. MySQL Stability ................................................................................ 91.4.4. How Large MySQL Tables Can Be ...................................................... 101.4.5. Year 2000 Compliance ...................................................................... 11

    1.5. Overview of the MaxDB Database Management System ..................................... 121.5.1. What is MaxDB? .............................................................................. 121.5.2. History of MaxDB ............................................................................ 131.5.3. Features of MaxDB ........................................................................... 131.5.4. Licensing and Support ....................................................................... 141.5.5. Feature Differences Between MaxDB and MySQL ................................. 141.5.6. Interoperability Features Between MaxDB and MySQL ........................... 151.5.7. MaxDB-Related Links ....................................................................... 15

    1.6. MySQL Development Roadmap ..................................................................... 151.6.1. What's New in MySQL 5.0 ................................................................. 16

    1.7. MySQL Information Sources ......................................................................... 181.7.1. MySQL Mailing Lists ........................................................................ 181.7.2. MySQL Community Support at the MySQL Forums ............................... 211.7.3. MySQL Community Support on Internet Relay Chat (IRC) ....................... 21

    1.8. How to Report Bugs or Problems ................................................................... 221.9. MySQL Standards Compliance ...................................................................... 26

    1.9.1. What Standards MySQL Follows ......................................................... 261.9.2. Selecting SQL Modes ........................................................................ 261.9.3. Running MySQL in ANSI Mode ......................................................... 271.9.4. MySQL Extensions to Standard SQL .................................................... 271.9.5. MySQL Differences from Standard SQL ............................................... 301.9.6. How MySQL Deals with Constraints .................................................... 36

    2. Installing and Upgrading MySQL ............................................................................. 402.1. General Installation Issues ............................................................................ 40

    2.1.1. Operating Systems Supported by MySQL .............................................. 412.1.2. Choosing Which MySQL Distribution to Install ...................................... 432.1.3. How to Get MySQL .......................................................................... 532.1.4. Verifying Package Integrity Using MD5 Checksums or GnuPG ................. 532.1.5. Installation Layouts ........................................................................... 56

    2.2. Standard MySQL Installation Using a Binary Distribution .................................. 582.3. Installing MySQL on Windows ...................................................................... 58

    2.3.1. Choosing An Installation Package ........................................................ 592.3.2. Installing MySQL with the Automated Installer ...................................... 592.3.3. Using the MySQL Installation Wizard .................................................. 602.3.4. Using the Configuration Wizard .......................................................... 622.3.5. Installing MySQL from a Noinstall Zip Archive ..................................... 672.3.6. Extracting the Install Archive .............................................................. 672.3.7. Creating an Option File ...................................................................... 682.3.8. Selecting a MySQL Server type ........................................................... 692.3.9. Starting the Server for the First Time .................................................... 702.3.10. Starting MySQL from the Windows Command Line .............................. 712.3.11. Starting MySQL as a Windows Service ............................................... 71

    iv

  • 2.3.12. Testing The MySQL Installation ........................................................ 742.3.13. Troubleshooting a MySQL Installation Under Windows ......................... 742.3.14. Upgrading MySQL on Windows ........................................................ 762.3.15. MySQL on Windows Compared to MySQL on Unix ............................. 77

    2.4. Installing MySQL on Linux ........................................................................... 792.5. Installing MySQL on Mac OS X .................................................................... 822.6. Installing MySQL on Solaris ......................................................................... 842.7. Installing MySQL on NetWare ...................................................................... 852.8. Installing MySQL on Other Unix-Like Systems ................................................ 872.9. MySQL Installation Using a Source Distribution ............................................... 89

    2.9.1. Source Installation Overview .............................................................. 902.9.2. Typical configure Options ............................................................. 932.9.3. Installing from the Development Source Tree ......................................... 962.9.4. Dealing with Problems Compiling MySQL ............................................ 982.9.5. MIT-pthreads Notes ........................................................................ 1012.9.6. Installing MySQL from Source on Windows ........................................ 1022.9.7. Compiling MySQL Clients on Windows ............................................. 106

    2.10. Post-Installation Setup and Testing ............................................................. 1062.10.1. Windows Post-Installation Procedures ............................................... 1072.10.2. Unix Post-Installation Procedures ..................................................... 1082.10.3. Securing the Initial MySQL Accounts ............................................... 118

    2.11. Upgrading MySQL .................................................................................. 1212.11.1. Upgrading from MySQL 5.0 to 5.1 ................................................... 1222.11.2. Upgrading from MySQL 4.1 to 5.0 ................................................... 1222.11.3. Copying MySQL Databases to Another Machine ................................ 129

    2.12. Downgrading MySQL .............................................................................. 1302.12.1. Downgrading to MySQL 4.1 ........................................................... 131

    2.13. Operating System-Specific Notes ................................................................ 1322.13.1. Linux Notes ................................................................................. 1322.13.2. Mac OS X Notes ........................................................................... 1392.13.3. Solaris Notes ................................................................................ 1402.13.4. BSD Notes ................................................................................... 1432.13.5. Other Unix Notes .......................................................................... 1472.13.6. OS/2 Notes .................................................................................. 162

    2.14. Perl Installation Notes .............................................................................. 1632.14.1. Installing Perl on Unix ................................................................... 1632.14.2. Installing ActiveState Perl on Windows ............................................. 1642.14.3. Problems Using the Perl DBI/DBD Interface ....................................... 165

    3. Tutorial .............................................................................................................. 1683.1. Connecting to and Disconnecting from the Server ............................................ 1683.2. Entering Queries ....................................................................................... 1693.3. Creating and Using a Database ..................................................................... 172

    3.3.1. Creating and Selecting a Database ...................................................... 1733.3.2. Creating a Table ............................................................................. 1743.3.3. Loading Data into a Table ................................................................ 1753.3.4. Retrieving Information from a Table .................................................. 176

    3.4. Getting Information About Databases and Tables ............................................ 1883.5. Using mysql in Batch Mode ...................................................................... 1893.6. Examples of Common Queries ..................................................................... 191

    3.6.1. The Maximum Value for a Column .................................................... 1913.6.2. The Row Holding the Maximum of a Certain Column ........................... 1913.6.3. Maximum of Column per Group ........................................................ 1923.6.4. The Rows Holding the Group-wise Maximum of a Certain Field .............. 1923.6.5. Using User-Defined Variables ........................................................... 1923.6.6. Using Foreign Keys ........................................................................ 1923.6.7. Searching on Two Keys ................................................................... 1943.6.8. Calculating Visits Per Day ................................................................ 1943.6.9. Using AUTO_INCREMENT ............................................................... 195

    MySQL 5.0 Reference Manual

    v

  • 3.7. Queries from the Twin Project ..................................................................... 1963.7.1. Find All Non-distributed Twins ......................................................... 1973.7.2. Show a Table of Twin Pair Status ...................................................... 199

    3.8. Using MySQL with Apache ........................................................................ 1994. Using MySQL Programs ....................................................................................... 200

    4.1. Overview of MySQL Programs .................................................................... 2004.2. Invoking MySQL Programs ........................................................................ 2014.3. Specifying Program Options ........................................................................ 202

    4.3.1. Using Options on the Command Line ................................................. 2034.3.2. Using Option Files .......................................................................... 2044.3.3. Using Environment Variables to Specify Options .................................. 2094.3.4. Using Options to Set Program Variables .............................................. 210

    5. Database Administration ....................................................................................... 2115.1. Overview of Server-Side Programs ............................................................... 2115.2. mysqld The MySQL Server .................................................................. 212

    5.2.1. mysqld Command Options ............................................................. 2135.2.2. Server System Variables .................................................................. 2245.2.3. Using System Variables ................................................................... 2505.2.4. Server Status Variables .................................................................... 2595.2.5. The Server SQL Mode ..................................................................... 2695.2.6. The MySQL Server Shutdown Process ............................................... 2745.2.7. MySQL Server-Side Help Support ..................................................... 275

    5.3. The mysqld-max Extended MySQL Server ................................................. 2765.4. MySQL Server Startup Programs ................................................................. 278

    5.4.1. mysqld_safe MySQL Server Startup Script ................................. 2785.4.2. mysql.server MySQL Server Startup Script ............................... 2825.4.3. mysqld_multi Manage Multiple MySQL Servers ......................... 282

    5.5. mysqlmanager The MySQL Instance Manager ....................................... 2865.5.1. Starting the MySQL Server with MySQL Instance Manager ................... 2865.5.2. Connecting to the MySQL Instance Manager and Creating User Accounts . 2875.5.3. MySQL Instance Manager Command Options ...................................... 2885.5.4. MySQL Instance Manager Configuration Files ..................................... 2905.5.5. Commands Recognized by the MySQL Instance Manager ...................... 291

    5.6. Installation-Related Programs ...................................................................... 2935.6.1. mysql_fix_privilege_tables Upgrade MySQL System Tables 2935.6.2. mysql_upgrade Check Tables for MySQL Upgrade ..................... 294

    5.7. General Security Issues .............................................................................. 2955.7.1. General Security Guidelines .............................................................. 2955.7.2. Making MySQL Secure Against Attackers .......................................... 2985.7.3. Security-Related mysqld Options ..................................................... 3005.7.4. Security Issues with LOAD DATA LOCAL .......................................... 3015.7.5. How to Run MySQL as a Normal User ............................................... 302

    5.8. The MySQL Access Privilege System ........................................................... 3025.8.1. What the Privilege System Does ........................................................ 3035.8.2. How the Privilege System Works ....................................................... 3035.8.3. Privileges Provided by MySQL ......................................................... 3075.8.4. Connecting to the MySQL Server ...................................................... 3115.8.5. Access Control, Stage 1: Connection Verification ................................. 3125.8.6. Access Control, Stage 2: Request Verification ...................................... 3155.8.7. When Privilege Changes Take Effect .................................................. 3185.8.8. Causes of Access denied Errors .................................................. 3185.8.9. Password Hashing as of MySQL 4.1 ................................................... 323

    5.9. MySQL User Account Management ............................................................. 3275.9.1. MySQL Usernames and Passwords .................................................... 3285.9.2. Adding New User Accounts to MySQL .............................................. 3295.9.3. Removing User Accounts from MySQL .............................................. 3325.9.4. Limiting Account Resources ............................................................. 3325.9.5. Assigning Account Passwords ........................................................... 334

    MySQL 5.0 Reference Manual

    vi

  • 5.9.6. Keeping Your Password Secure ......................................................... 3355.9.7. Using Secure Connections ................................................................ 336

    5.10. Backup and Recovery ............................................................................... 3435.10.1. Database Backups ......................................................................... 3435.10.2. Example Backup and Recovery Strategy ............................................ 3455.10.3. Point-in-Time Recovery ................................................................. 3485.10.4. Table Maintenance and Crash Recovery ............................................ 349

    5.11. MySQL Localization and International Usage ............................................... 3615.11.1. The Character Set Used for Data and Sorting ...................................... 3615.11.2. Setting the Error Message Language ................................................. 3625.11.3. Adding a New Character Set ........................................................... 3625.11.4. The Character Definition Arrays ...................................................... 3645.11.5. String Collating Support ................................................................. 3645.11.6. Multi-Byte Character Support .......................................................... 3655.11.7. Problems With Character Sets ......................................................... 3655.11.8. MySQL Server Time Zone Support .................................................. 365

    5.12. MySQL Server Logs ................................................................................ 3675.12.1. The Error Log .............................................................................. 3675.12.2. The General Query Log .................................................................. 3685.12.3. The Binary Log ............................................................................ 3685.12.4. The Slow Query Log ..................................................................... 3725.12.5. Server Log Maintenance ................................................................. 372

    5.13. Running Multiple MySQL Servers on the Same Machine ................................ 3735.13.1. Running Multiple Servers on Windows ............................................. 3755.13.2. Running Multiple Servers on Unix ................................................... 3785.13.3. Using Client Programs in a Multiple-Server Environment ..................... 379

    5.14. The MySQL Query Cache ......................................................................... 3805.14.1. How the Query Cache Operates ....................................................... 3815.14.2. Query Cache SELECT Options ........................................................ 3825.14.3. Query Cache Configuration ............................................................. 3825.14.4. Query Cache Status and Maintenance ............................................... 384

    6. Replication ......................................................................................................... 3866.1. Introduction to Replication .......................................................................... 3866.2. Replication Implementation Overview ........................................................... 3866.3. Replication Implementation Details .............................................................. 387

    6.3.1. Replication Master Thread States ....................................................... 3886.3.2. Replication Slave I/O Thread States ................................................... 3896.3.3. Replication Slave SQL Thread States .................................................. 3906.3.4. Replication Relay and Status Files ..................................................... 390

    6.4. How to Set Up Replication .......................................................................... 3926.5. Replication Compatibility Between MySQL Versions ...................................... 3966.6. Upgrading a Replication Setup ..................................................................... 397

    6.6.1. Upgrading Replication to 5.0 ............................................................ 3976.7. Replication Features and Known Problems ..................................................... 3976.8. Replication Startup Options ......................................................................... 4036.9. How Servers Evaluate Replication Rules ....................................................... 4096.10. Replication FAQ ..................................................................................... 4126.11. Troubleshooting Replication ...................................................................... 4186.12. How to Report Replication Bugs or Problems ............................................... 4196.13. Auto-Increment in Multiple-Master Replication ............................................. 420

    7. Optimization ....................................................................................................... 4217.1. Optimization Overview .............................................................................. 421

    7.1.1. MySQL Design Limitations and Tradeoffs .......................................... 4217.1.2. Designing Applications for Portability ................................................ 4227.1.3. What We Have Used MySQL For ...................................................... 4237.1.4. The MySQL Benchmark Suite ........................................................... 4237.1.5. Using Your Own Benchmarks ........................................................... 424

    7.2. Optimizing SELECT and Other Statements .................................................... 425

    MySQL 5.0 Reference Manual

    vii

  • 7.2.1. Optimizing Queries with EXPLAIN ................................................... 4257.2.2. Estimating Query Performance .......................................................... 4347.2.3. Speed of SELECT Queries ................................................................ 4347.2.4. WHERE Clause Optimization ............................................................. 4357.2.5. Range Optimization ........................................................................ 4377.2.6. Index Merge Optimization ................................................................ 4407.2.7. IS NULL Optimization ................................................................... 4437.2.8. DISTINCT Optimization ................................................................. 4437.2.9. LEFT JOIN and RIGHT JOIN Optimization .................................... 4447.2.10. Nested Join Optimization ................................................................ 4457.2.11. Outer Join Simplification ................................................................ 4507.2.12. ORDER BY Optimization ............................................................... 4537.2.13. GROUP BY Optimization ............................................................... 4557.2.14. LIMIT Optimization ..................................................................... 4567.2.15. How to Avoid Table Scans .............................................................. 4577.2.16. Speed of INSERT Statements .......................................................... 4587.2.17. Speed of UPDATE Statements .......................................................... 4607.2.18. Speed of DELETE Statements .......................................................... 4607.2.19. Other Optimization Tips ................................................................. 460

    7.3. Locking Issues .......................................................................................... 4637.3.1. Locking Methods ............................................................................ 4637.3.2. Table Locking Issues ....................................................................... 4657.3.3. Concurrent Inserts ........................................................................... 466

    7.4. Optimizing Database Structure ..................................................................... 4677.4.1. Design Choices .............................................................................. 4677.4.2. Make Your Data as Small as Possible ................................................. 4677.4.3. Column Indexes ............................................................................. 4687.4.4. Multiple-Column Indexes ................................................................. 4697.4.5. How MySQL Uses Indexes ............................................................... 4707.4.6. The MyISAM Key Cache .................................................................. 4727.4.7. MyISAM Index Statistics Collection ................................................... 4777.4.8. How MySQL Opens and Closes Tables ............................................... 4787.4.9. Drawbacks to Creating Many Tables in the Same Database ..................... 480

    7.5. Optimizing the MySQL Server .................................................................... 4807.5.1. System Factors and Startup Parameter Tuning ...................................... 4807.5.2. Tuning Server Parameters ................................................................. 4817.5.3. Controlling Query Optimizer Performance ........................................... 4837.5.4. How Compiling and Linking Affects the Speed of MySQL ..................... 4847.5.5. How MySQL Uses Memory ............................................................. 4857.5.6. How MySQL Uses DNS .................................................................. 487

    7.6. Disk Issues ............................................................................................... 4877.6.1. Using Symbolic Links ..................................................................... 488

    8. Client and Utility Programs ................................................................................... 4928.1. Overview of Client and Utility Programs ....................................................... 4928.2. myisam_ftdump Display Full-Text Index information .............................. 4948.3. myisamchk MyISAM Table-Maintenance Utility ...................................... 495

    8.3.1. myisamchk General Options ........................................................... 4968.3.2. myisamchk Check Options ............................................................. 4988.3.3. myisamchk Repair Options ............................................................ 4998.3.4. Other myisamchk Options .............................................................. 5018.3.5. myisamchk Memory Usage ............................................................ 501

    8.4. myisamlog Display MyISAM Log File Contents ...................................... 5028.5. myisampack Generate Compressed, Read-Only MyISAM Tables ................ 5038.6. mysql The MySQL Command-Line Tool ................................................. 509

    8.6.1. mysql Options .............................................................................. 5108.6.2. mysql Commands ......................................................................... 5158.6.3. mysql Server-Side Help ................................................................. 5188.6.4. Executing SQL Statements from a Text File ......................................... 519

    MySQL 5.0 Reference Manual

    viii

  • 8.6.5. mysql Tips ................................................................................... 5198.7. mysql_explain_log Use EXPLAIN on Statements in Query Log ............ 5218.8. mysqlaccess Client for Checking Access Privileges ................................ 5228.9. mysqladmin Client for Administering a MySQL Server ............................ 5248.10. mysqlbinlog Utility for Processing Binary Log Files ............................. 5298.11. mysqlcheck A Table Maintenance and Repair Program ........................... 5358.12. mysqldump A Database Backup Program .............................................. 5398.13. mysqlhotcopy A Database Backup Program ........................................ 5478.14. mysqlimport A Data Import Program ................................................. 5498.15. mysqlshow Display Database, Table, and Column Information .................. 5528.16. mysql_zap Kill Processes That Match a Pattern ..................................... 5548.17. perror Explain Error Codes ................................................................ 5558.18. replace A String-Replacement Utility .................................................. 556

    9. Language Structure .............................................................................................. 5579.1. Literal Values ........................................................................................... 557

    9.1.1. Strings .......................................................................................... 5579.1.2. Numbers ....................................................................................... 5599.1.3. Hexadecimal Values ........................................................................ 5599.1.4. Boolean Values .............................................................................. 5609.1.5. Bit-Field Values ............................................................................. 5609.1.6. NULL Values ................................................................................. 560

    9.2. Database, Table, Index, Column, and Alias Names .......................................... 5619.2.1. Identifier Qualifiers ......................................................................... 5629.2.2. Identifier Case Sensitivity ................................................................. 562

    9.3. User-Defined Variables .............................................................................. 5649.4. Comment Syntax ....................................................................................... 5659.5. Treatment of Reserved Words in MySQL ...................................................... 566

    10. Character Set Support ......................................................................................... 57010.1. Character Sets and Collations in General ...................................................... 57010.2. Character Sets and Collations in MySQL ..................................................... 57110.3. Specifying Character Sets and Collations ..................................................... 572

    10.3.1. Server Character Set and Collation ................................................... 57210.3.2. Database Character Set and Collation ................................................ 57310.3.3. Table Character Set and Collation .................................................... 57410.3.4. Column Character Set and Collation ................................................. 57410.3.5. Character String Literal Character Set and Collation ............................ 57510.3.6. National Character Set ................................................................... 57610.3.7. Examples of Character Set and Collation Assignment .......................... 57610.3.8. Compatibility with Other DBMSs .................................................... 577

    10.4. Connection Character Sets and Collations .................................................... 57710.5. Collation Issues ....................................................................................... 579

    10.5.1. Using COLLATE in SQL Statements ................................................. 57910.5.2. COLLATE Clause Precedence .......................................................... 58010.5.3. BINARY Operator ......................................................................... 58010.5.4. Some Special Cases Where the Collation Determination Is Tricky .......... 58110.5.5. Collations Must Be for the Right Character Set ................................... 58210.5.6. An Example of the Effect of Collation ............................................... 582

    10.6. Operations Affected by Character Set Support ............................................... 58310.6.1. Result Strings ............................................................................... 58310.6.2. CONVERT() and CAST() ............................................................. 58410.6.3. SHOW Statements and INFORMATION_SCHEMA ................................ 585

    10.7. Unicode Support ..................................................................................... 58610.8. UTF-8 for Metadata ................................................................................. 58710.9. Character Sets and Collations That MySQL Supports ..................................... 588

    10.9.1. Unicode Character Sets .................................................................. 58910.9.2. West European Character Sets ......................................................... 59110.9.3. Central European Character Sets ...................................................... 59310.9.4. South European and Middle East Character Sets ................................. 593

    MySQL 5.0 Reference Manual

    ix

  • 10.9.5. Baltic Character Sets ...................................................................... 59410.9.6. Cyrillic Character Sets ................................................................... 59510.9.7. Asian Character Sets ...................................................................... 595

    10.10. FAQ: MySQL Chinese, Japanese, and Korean Character Sets ......................... 59910.10.1. SELECT shows non-Latin characters as "?"s. Why? ........................... 59910.10.2. Troubles with GB character sets (Chinese) ....................................... 60010.10.3. Troubles with big5 character set (Chinese) ....................................... 60110.10.4. Troubles with character-set conversions (Japanese) ............................ 60110.10.5. The Great Yen Sign problem (Japanese) .......................................... 60210.10.6. Troubles with euckr character set (Korean) ....................................... 60210.10.7. The Data truncated message ....................................................... 60210.10.8. Troubles with Access, Perl, PHP, etc. .............................................. 60310.10.9. How can I get old MySQL 4.0 behaviour back? ................................. 60410.10.10. Why do some LIKE and FULLTEXT searches fail? ......................... 60510.10.11. What CJK character sets are available? .......................................... 60510.10.12. Is character X available in all character sets? ................................... 60610.10.13. Strings don't sort correctly in Unicode (I) ....................................... 60710.10.14. Strings don't sort correctly in Unicode (II) ...................................... 60710.10.15. My supplementary characters get rejected ....................................... 60810.10.16. Shouldn't it be CJKV (V for Vietnamese)? ...................................... 60810.10.17. Will MySQL fix any CJK problems in version 5.1? .......................... 60810.10.18. When will MySQL translate the manual again? ............................... 60910.10.19. Whom can I talk to? ................................................................... 609

    11. Data Types ....................................................................................................... 61011.1. Data Type Overview ................................................................................ 610

    11.1.1. Overview of Numeric Types ........................................................... 61011.1.2. Overview of Date and Time Types ................................................... 61411.1.3. Overview of String Types ............................................................... 61511.1.4. Data Type Default Values ............................................................... 618

    11.2. Numeric Types ........................................................................................ 61911.3. Date and Time Types ............................................................................... 622

    11.3.1. The DATETIME, DATE, and TIMESTAMP Types ................................ 62311.3.2. The TIME Type ............................................................................ 62811.3.3. The YEAR Type ............................................................................ 62811.3.4. Y2K Issues and Date Types ............................................................ 629

    11.4. String Types ........................................................................................... 62911.4.1. The CHAR and VARCHAR Types ...................................................... 62911.4.2. The BINARY and VARBINARY Types .............................................. 63111.4.3. The BLOB and TEXT Types ............................................................ 63211.4.4. The ENUM Type ............................................................................ 63411.4.5. The SET Type .............................................................................. 636

    11.5. Data Type Storage Requirements ................................................................ 63811.6. Choosing the Right Type for a Column ........................................................ 64111.7. Using Data Types from Other Database Engines ............................................ 641

    12. Functions and Operators ...................................................................................... 64312.1. Operators ............................................................................................... 643

    12.1.1. Operator Precedence ...................................................................... 64312.1.2. Type Conversion in Expression Evaluation ........................................ 64412.1.3. Comparison Functions and Operators ................................................ 64512.1.4. Logical Operators .......................................................................... 649

    12.2. Control Flow Functions ............................................................................ 65112.3. String Functions ...................................................................................... 653

    12.3.1. String Comparison Functions .......................................................... 66212.4. Numeric Functions ................................................................................... 664

    12.4.1. Arithmetic Operators ..................................................................... 66412.4.2. Mathematical Functions ................................................................. 666

    12.5. Date and Time Functions .......................................................................... 67212.6. What Calendar Is Used By MySQL? ........................................................... 687

    MySQL 5.0 Reference Manual

    x

  • 12.7. Full-Text Search Functions ........................................................................ 68812.7.1. Boolean Full-Text Searches ............................................................ 69112.7.2. Full-Text Searches with Query Expansion .......................................... 69312.7.3. Full-Text Stopwords ...................................................................... 69412.7.4. Full-Text Restrictions .................................................................... 69712.7.5. Fine-Tuning MySQL Full-Text Search .............................................. 697

    12.8. Cast Functions and Operators ..................................................................... 69912.9. Other Functions ....................................................................................... 701

    12.9.1. Bit Functions ................................................................................ 70112.9.2. Encryption and Compression Functions ............................................. 70212.9.3. Information Functions .................................................................... 70712.9.4. Miscellaneous Functions ................................................................ 712

    12.10. Functions and Modifiers for Use with GROUP BY Clauses ............................ 71512.10.1. GROUP BY (Aggregate) Functions ................................................. 71512.10.2. GROUP BY Modifiers .................................................................. 71912.10.3. GROUP BY and HAVING with Hidden Fields ................................... 721

    13. SQL Statement Syntax ........................................................................................ 72313.1. Data Definition Statements ........................................................................ 723

    13.1.1. ALTER DATABASE Syntax ............................................................ 72313.1.2. ALTER TABLE Syntax .................................................................. 72313.1.3. CREATE DATABASE Syntax .......................................................... 72913.1.4. CREATE INDEX Syntax ................................................................ 72913.1.5. CREATE TABLE Syntax ................................................................ 73113.1.6. DROP DATABASE Syntax .............................................................. 74113.1.7. DROP INDEX Syntax .................................................................... 74213.1.8. DROP TABLE Syntax .................................................................... 74213.1.9. RENAME TABLE Syntax ................................................................ 743

    13.2. Data Manipulation Statements .................................................................... 74313.2.1. DELETE Syntax ............................................................................ 74313.2.2. DO Syntax .................................................................................... 74613.2.3. HANDLER Syntax .......................................................................... 74613.2.4. INSERT Syntax ............................................................................ 74813.2.5. LOAD DATA INFILE Syntax ........................................................ 75413.2.6. REPLACE Syntax .......................................................................... 76213.2.7. SELECT Syntax ............................................................................ 76413.2.8. Subquery Syntax ........................................................................... 77813.2.9. TRUNCATE Syntax ........................................................................ 78813.2.10. UPDATE Syntax .......................................................................... 788

    13.3. MySQL Utility Statements ........................................................................ 79013.3.1. DESCRIBE Syntax ........................................................................ 79013.3.2. HELP Syntax ................................................................................ 79113.3.3. USE Syntax .................................................................................. 793

    13.4. MySQL Transactional and Locking Statements ............................................. 79313.4.1. START TRANSACTION, COMMIT, and ROLLBACK Syntax ................. 79413.4.2. Statements That Cannot Be Rolled Back ............................................ 79513.4.3. Statements That Cause an Implicit Commit ........................................ 79513.4.4. SAVEPOINT and ROLLBACK TO SAVEPOINT Syntax ..................... 79613.4.5. LOCK TABLES and UNLOCK TABLES Syntax ................................. 79713.4.6. SET TRANSACTION Syntax .......................................................... 79913.4.7. XA Transactions ........................................................................... 799

    13.5. Database Administration Statements ........................................................... 80313.5.1. Account Management Statements ..................................................... 80313.5.2. Table Maintenance Statements ......................................................... 81313.5.3. SET Syntax .................................................................................. 81913.5.4. SHOW Syntax ................................................................................ 82413.5.5. Other Administrative Statements ...................................................... 845

    13.6. Replication Statements ............................................................................. 85013.6.1. SQL Statements for Controlling Master Servers .................................. 850

    MySQL 5.0 Reference Manual

    xi

  • 13.6.2. SQL Statements for Controlling Slave Servers .................................... 85213.7. SQL Syntax for Prepared Statements ........................................................... 859

    14. Storage Engines and Table Types .......................................................................... 86314.1. The MyISAM Storage Engine ..................................................................... 865

    14.1.1. MyISAM Startup Options ................................................................ 86714.1.2. Space Needed for Keys .................................................................. 86814.1.3. MyISAM Table Storage Formats ...................................................... 86914.1.4. MyISAM Table Problems ................................................................ 871

    14.2. The InnoDB Storage Engine ..................................................................... 87314.2.1. InnoDB Overview ........................................................................ 87314.2.2. InnoDB Contact Information .......................................................... 87314.2.3. InnoDB Configuration .................................................................. 87314.2.4. InnoDB Startup Options and System Variables .................................. 87914.2.5. Creating the InnoDB Tablespace ..................................................... 88614.2.6. Creating and Using InnoDB Tables ................................................. 88714.2.7. Adding and Removing InnoDB Data and Log Files ............................ 89414.2.8. Backing Up and Recovering an InnoDB Database .............................. 89614.2.9. Moving an InnoDB Database to Another Machine .............................. 89814.2.10. InnoDB Transaction Model and Locking ........................................ 89914.2.11. InnoDB Performance Tuning Tips ................................................. 90814.2.12. Implementation of Multi-Versioning ............................................... 91414.2.13. InnoDB Table and Index Structures ............................................... 91514.2.14. InnoDB File Space Management and Disk I/O ................................. 91714.2.15. InnoDB Error Handling ............................................................... 91914.2.16. Restrictions on InnoDB Tables ..................................................... 92514.2.17. InnoDB Troubleshooting ............................................................. 927

    14.3. The MERGE Storage Engine ....................................................................... 92914.3.1. MERGE Table Problems .................................................................. 931

    14.4. The MEMORY (HEAP) Storage Engine .......................................................... 93214.5. The BDB (BerkeleyDB) Storage Engine .................................................... 934

    14.5.1. Operating Systems Supported by BDB ............................................... 93414.5.2. Installing BDB .............................................................................. 93514.5.3. BDB Startup Options ...................................................................... 93514.5.4. Characteristics of BDB Tables .......................................................... 93714.5.5. Things We Need to Fix for BDB ....................................................... 93814.5.6. Restrictions on BDB Tables ............................................................. 93914.5.7. Errors That May Occur When Using BDB Tables ................................ 939

    14.6. The EXAMPLE Storage Engine ................................................................... 94014.7. The FEDERATED Storage Engine ............................................................... 940

    14.7.1. Description of the FEDERATED Storage Engine ................................. 94014.7.2. How to use FEDERATED Tables ...................................................... 94114.7.3. Limitations of the FEDERATED Storage Engine .................................. 942

    14.8. The ARCHIVE Storage Engine ................................................................... 94314.9. The CSV Storage Engine ........................................................................... 94414.10. The BLACKHOLE Storage Engine ............................................................. 944

    15. MySQL Cluster ................................................................................................. 94715.1. MySQL Cluster Overview ......................................................................... 94715.2. Basic MySQL Cluster Concepts ................................................................. 948

    15.2.1. MySQL Cluster Nodes, Node Groups, Replicas, and Partitions .............. 94915.3. Simple Multi-Computer How-To ................................................................ 952

    15.3.1. Hardware, Software, and Networking ................................................ 95415.3.2. Multi-Computer Installation ............................................................ 95515.3.3. Multi-Computer Configuration ........................................................ 95715.3.4. Initial Startup ............................................................................... 95815.3.5. Loading Sample Data and Performing Queries .................................... 95915.3.6. Safe Shutdown and Restart ............................................................. 962

    15.4. MySQL Cluster Configuration ................................................................... 96315.4.1. Building MySQL Cluster from Source Code ....................................... 963

    MySQL 5.0 Reference Manual

    xii

  • 15.4.2. Installing the Software ................................................................... 96415.4.3. Quick Test Setup of MySQL Cluster ................................................. 96415.4.4. Configuration File ......................................................................... 96615.4.5. Overview of Cluster Configuration Parameters ................................... 99415.4.6. Configuring Parameters for Local Checkpoints .................................. 1004

    15.5. Upgrading and Downgrading MySQL Cluster .............................................. 100615.5.1. Performing a Rolling Upgrade or Downgrade .................................... 100615.5.2. Cluster Upgrade and Downgrade Compatibility ................................. 1007

    15.6. Process Management in MySQL Cluster ..................................................... 100915.6.1. MySQL Server Process Usage for MySQL Cluster ............................. 100915.6.2. ndbd, the Storage Engine Node Process ........................................... 101015.6.3. ndb_mgmd, the Management Server Process .................................... 101215.6.4. ndb_mgm, the Management Client Process ....................................... 101215.6.5. Command Options for MySQL Cluster Processes ............................... 1013

    15.7. Management of MySQL Cluster ................................................................ 101615.7.1. MySQL Cluster Startup Phases ....................................................... 101615.7.2. Commands in the Management Client .............................................. 101915.7.3. Event Reports Generated in MySQL Cluster ...................................... 102015.7.4. Single-User Mode ........................................................................ 1026

    15.8. On-line Backup of MySQL Cluster ............................................................ 102715.8.1. Cluster Backup Concepts ............................................................... 102715.8.2. Using The Management Client to Create a Backup ............................. 102815.8.3. How to Restore a Cluster Backup .................................................... 102915.8.4. Configuration for Cluster Backup .................................................... 102915.8.5. Backup Troubleshooting ................................................................ 1030

    15.9. Using High-Speed Interconnects with MySQL Cluster ................................... 103015.9.1. Configuring MySQL Cluster to use SCI Sockets ................................ 103015.9.2. Understanding the Impact of Cluster Interconnects ............................. 1034

    15.10. Known Limitations of MySQL Cluster ...................................................... 103515.11. MySQL Cluster Development Roadmap .................................................... 1041

    15.11.1. MySQL Cluster Changes in MySQL 5.0 ......................................... 104115.11.2. MySQL 5.1 Development Roadmap for MySQL Cluster .................... 1042

    15.12. MySQL Cluster FAQ ............................................................................. 104215.13. MySQL Cluster Glossary ....................................................................... 1050

    16. Spatial Extensions ............................................................................................. 105516.1. Introduction to MySQL Spatial Support ...................................................... 105516.2. The OpenGIS Geometry Model ................................................................. 1056

    16.2.1. The Geometry Class Hierarchy ....................................................... 105616.2.2. Class Geometry ......................................................................... 105716.2.3. Class Point ............................................................................... 105816.2.4. Class Curve ............................................................................... 105916.2.5. Class LineString ..................................................................... 105916.2.6. Class Surface ........................................................................... 105916.2.7. Class Polygon ........................................................................... 106016.2.8. Class GeometryCollection ..................................................... 106016.2.9. Class MultiPoint ..................................................................... 106116.2.10. Class MultiCurve ................................................................... 106116.2.11. Class MultiLineString ......................................................... 106116.2.12. Class MultiSurface ............................................................... 106216.2.13. Class MultiPolygon ............................................................... 1062

    16.3. Supported Spatial Data Formats ................................................................ 106216.3.1. Well-Known Text (WKT) Format ................................................... 106316.3.2. Well-Known Binary (WKB) Format ................................................ 1063

    16.4. Creating a Spatially Enabled MySQL Database ............................................ 106416.4.1. MySQL Spatial Data Types ............................................................ 106416.4.2. Creating Spatial Values ................................................................. 106516.4.3. Creating Spatial Columns .............................................................. 106816.4.4. Populating Spatial Columns ........................................................... 1068

    MySQL 5.0 Reference Manual

    xiii

  • 16.4.5. Fetching Spatial Data .................................................................... 106916.5. Analyzing Spatial Information .................................................................. 1070

    16.5.1. Geometry Format Conversion Functions ........................................... 107016.5.2. Geometry Functions ................................................................... 107116.5.3. Functions That Create New Geometries from Existing Ones ................. 107616.5.4. Functions for Testing Spatial Relations Between Geometric Objects ...... 107716.5.5. Relations on Geometry Minimal Bounding Rectangles (MBRs) ............ 107716.5.6. Functions That Test Spatial Relationships Between Geometries ............ 1078

    16.6. Optimizing Spatial Analysis ..................................................................... 108016.6.1. Creating Spatial Indexes ................................................................ 108016.6.2. Using a Spatial Index .................................................................... 1081

    16.7. MySQL Conformance and Compatibility .................................................... 108217. Stored Procedures and Functions .......................................................................... 1084

    17.1. Stored Routines and the Grant Tables ......................................................... 108417.2. Stored Routine Syntax ............................................................................. 1085

    17.2.1. CREATE PROCEDURE and CREATE FUNCTION Syntax .................. 108517.2.2. ALTER PROCEDURE and ALTER FUNCTION Syntax ...................... 108917.2.3. DROP PROCEDURE and DROP FUNCTION Syntax .......................... 108917.2.4. CALL Statement Syntax ................................................................ 108917.2.5. BEGIN ... END Compound Statement Syntax ............................... 109017.2.6. DECLARE Statement Syntax .......................................................... 109017.2.7. Variables in Stored Routines .......................................................... 109117.2.8. Conditions and Handlers ................................................................ 109217.2.9. Cursors ...................................................................................... 109317.2.10. Flow Control Constructs .............................................................. 1094

    17.3. Stored Procedures, Functions, Triggers, and Replication: Frequently Asked Questions.................................................................................................................... 109717.4. Binary Logging of Stored Routines and Triggers .......................................... 1098

    18. Triggers .......................................................................................................... 110718.1. CREATE TRIGGER Syntax ..................................................................... 110718.2. DROP TRIGGER Syntax ......................................................................... 111018.3. Using Triggers ....................................................................................... 1111

    19. Views ............................................................................................................. 111419.1. ALTER VIEW Syntax ............................................................................. 111419.2. CREATE VIEW Syntax ........................................................................... 111419.3. DROP VIEW Syntax ............................................................................... 1121

    20. The INFORMATION_SCHEMA Database ............................................................... 112220.1. The INFORMATION_SCHEMA SCHEMATA Table ....................................... 112420.2. The INFORMATION_SCHEMA TABLES Table ........................................... 112420.3. The INFORMATION_SCHEMA COLUMNS Table ......................................... 112520.4. The INFORMATION_SCHEMA STATISTICS Table ................................... 112620.5. The INFORMATION_SCHEMA USER_PRIVILEGES Table ......................... 112720.6. The INFORMATION_SCHEMA SCHEMA_PRIVILEGES Table ..................... 112820.7. The INFORMATION_SCHEMA TABLE_PRIVILEGES Table ....................... 112820.8. The INFORMATION_SCHEMA COLUMN_PRIVILEGES Table ..................... 112920.9. The INFORMATION_SCHEMA CHARACTER_SETS Table ........................... 112920.10. The INFORMATION_SCHEMA COLLATIONS Table ................................. 113020.11. The INFORMATION_SCHEMA COLLA-TION_CHARACTER_SET_APPLICABILITY Table .......................................... 113020.12. The INFORMATION_SCHEMA TABLE_CONSTRAINTS Table ................... 113020.13. The INFORMATION_SCHEMA KEY_COLUMN_USAGE Table ..................... 113120.14. The INFORMATION_SCHEMA ROUTINES Table ..................................... 113220.15. The INFORMATION_SCHEMA VIEWS Table ........................................... 113320.16. The INFORMATION_SCHEMA TRIGGERS Table ..................................... 113420.17. Other INFORMATION_SCHEMA Tables ................................................... 113520.18. Extensions to SHOW Statements ............................................................... 1136

    21. Precision Math ................................................................................................. 113821.1. Types of Numeric Values ......................................................................... 1138

    MySQL 5.0 Reference Manual

    xiv

  • 21.2. DECIMAL Data Type Changes .................................................................. 113921.3. Expression Handling ............................................................................... 114121.4. Rounding Behavior ................................................................................. 114221.5. Precision Math Examples ......................................................................... 1143

    22. APIs and Libraries ............................................................................................ 114822.1. libmysqld, the Embedded MySQL Server Library ......................................... 114822.2. MySQL C API ....................................................................................... 1148

    22.2.1. C API Data types ......................................................................... 114922.2.2. C API Function Overview .............................................................. 115322.2.3. C API Function Descriptions .......................................................... 115722.2.4. C API Prepared Statements ............................................................ 120422.2.5. C API Prepared Statement Data types .............................................. 120422.2.6. C API Prepared Statement Function Overview ................................... 120822.2.7. C API Prepared Statement Function Descriptions ............................... 121022.2.8. C API Prepared statement problems ................................................. 123222.2.9. C API Handling of Multiple Statement Execution ............................... 123222.2.10. C API Handling of Date and Time Values ....................................... 123322.2.11. C API Threaded Function Descriptions ........................................... 123422.2.12. C API Embedded Server Function Descriptions ................................ 123522.2.13. Common Questions and Problems When Using the C API .................. 123722.2.14. Building Client Programs ............................................................. 123822.2.15. How to Make a Threaded Client .................................................... 1239

    22.3. MySQL PHP API ................................................................................... 124022.3.1. Common Problems with MySQL and PHP ........................................ 124122.3.2. Enabling Both mysql and mysqli in PHP ...................................... 1241

    22.4. MySQL Perl API .................................................................................... 124222.5. MySQL C++ API ................................................................................... 1242

    22.5.1. Borland C++ ............................................................................... 124322.6. MySQL Python API ................................................................................ 124322.7. MySQL Tcl API ..................................................................................... 124322.8. MySQL Eiffel Wrapper ........................................................................... 124322.9. MySQL Program Development Utilities ...................................................... 1243

    22.9.1. msql2mysql Convert mSQL Programs for Use with MySQL ........ 124322.9.2. mysql_config Get Compile Options for Compiling Clients ......... 1244

    23. Connectors ...................................................................................................... 124623.1. MySQL Connector/ODBC ....................................................................... 1246

    23.1.1. Introduction to MyODBC .............................................................. 124723.1.2. How to Install MyODBC ............................................................... 125023.1.3. MyODBC Configuration ............................................................... 127023.1.4. MyODBC Examples ..................................................................... 128623.1.5. MyODBC Reference .................................................................... 130223.1.6. MyODBC Notes and Tips .............................................................. 130823.1.7. MyODBC Support ....................................................................... 1318

    23.2. Connector/NET ...................................................................................... 131923.2.1. Connector/NET Versions ............................................................... 132023.2.2. How to install Connector/NET ........................................................ 132023.2.3. Connector/NET Examples ............................................................. 132723.2.4. Connector/NET Reference ............................................................. 137523.2.5. Connector/NET Notes and Tips ...................................................... 148923.2.6. Connector/NET Support ................................................................ 1506

    23.3. MySQL Connector/J ............................................................................... 150723.3.1. Basic JDBC concepts .................................................................... 150723.3.2. Installing Connector/J ................................................................... 151623.3.3. JDBC Reference .......................................................................... 152023.3.4. Using Connector/J with J2EE and Other Java Frameworks ................... 153823.3.5. Diagnosing Connector/J Problems ................................................... 154323.3.6. MySQL Connector/J Change History ............................................... 1549

    23.4. MySQL Connector/MXJ .......................................................................... 1595

    MySQL 5.0 Reference Manual

    xv

  • 23.4.1. Introduction ................................................................................ 159623.4.2. Supported Platforms ..................................................................... 159623.4.3. JUnit Test Requirements ................................................................ 159623.4.4. Running the JUnit Tests ................................................................ 159723.4.5. Running as part of the JDBC Driver ................................................. 159823.4.6. Running within a Java Object ......................................................... 159923.4.7. The MysqldResource API .............................................................. 159923.4.8. Running within a JMX Agent (custom) ............................................ 160123.4.9. Deployment in a standard JMX Agent environment (JBoss) ................. 160223.4.10. Installation ................................................................................ 1603

    23.5. Connector/PHP ...................................................................................... 160424. Extending MySQL ............................................................................................ 1605

    24.1. MySQL Internals .................................................................................... 160524.1.1. MySQL Threads .......................................................................... 160524.1.2. MySQL Test Suite ....................................................................... 1605

    24.2. Adding New Functions to MySQL ............................................................. 160624.2.1. Features of the User-Defined Function Interface ................................. 160724.2.2. CREATE FUNCTION Syntax ......................................................... 160724.2.3. DROP FUNCTION Syntax ............................................................. 160824.2.4. Adding a New User-Defined Function .............................................. 160824.2.5. Adding a New Native Function ....................................................... 1617

    24.3. Adding New Procedures to MySQL ........................................................... 161824.3.1. Procedure Analyse ....................................................................... 161824.3.2. Writing a Procedure ...................................................................... 1618

    A. Problems and Common Errors .............................................................................. 1620A.1. How to Determine What Is Causing a Problem .............................................. 1620A.2. Common Errors When Using MySQL Programs ............................................ 1621

    A.2.1. Access denied ........................................................................ 1621A.2.2. Can't connect to [local] MySQL server ........................ 1621A.2.3. Client does not support authentication protocol .... 1624A.2.4. Password Fails When Entered Interactively ........................................ 1625A.2.5. Host 'host_name' is blocked ............................................ 1626A.2.6. Too many connections .......................................................... 1626A.2.7. Out of memory ........................................................................ 1626A.2.8. MySQL server has gone away .............................................. 1627A.2.9. Packet too large .................................................................. 1629A.2.10. Communication Errors and Aborted Connections .............................. 1629A.2.11. The table is full .............................................................. 1630A.2.12. Can't create/write to file ............................................ 1631A.2.13. Commands out of sync ........................................................ 1632A.2.14. Ignoring user ...................................................................... 1632A.2.15. Table 'tbl_name' doesn't exist .................................... 1632A.2.16. Can't initialize character set .................................... 1633A.2.17. File Not Found ............................................................................ 1633

    A.3. Installation-Related Issues ......................................................................... 1634A.3.1. Problems Linking to the MySQL Client Library .................................. 1634A.3.2. Problems with File Permissions ....................................................... 1635

    A.4. Administration-Related Issues .................................................................... 1635A.4.1. How to Reset the Root Password ...................................................... 1635A.4.2. What to Do If MySQL Keeps Crashing ............................................. 1638A.4.3. How MySQL Handles a Full Disk .................................................... 1640A.4.4. Where MySQL Stores Temporary Files ............................................. 1640A.4.5. How to Protect or Change the MySQL Unix Socket File ....................... 1641A.4.6. Time Zone Problems ..................................................................... 1642

    A.5. Query-Related Issues ............................................................................... 1642A.5.1. Case Sensitivity in Searches ............................................................ 1642A.5.2. Problems Using DATE Columns ...................................................... 1643A.5.3. Problems with NULL Values ........................................................... 1644

    MySQL 5.0 Reference Manual

    xvi

  • A.5.4. Problems with Column Aliases ........................................................ 1645A.5.5. Rollback Failure for Non-Transactional Tables ................................... 1645A.5.6. Deleting Rows from Related Tables .................................................. 1646A.5.7. Solving Problems with No Matching Rows ........................................ 1646A.5.8. Problems with Floating-Point Comparisons ........................................ 1647

    A.6. Optimizer-Related Issues .......................................................................... 1649A.7. Table Definition-Related Issues .................................................................. 1649

    A.7.1. Problems with ALTER TABLE ....................................................... 1649A.7.2. How to Change the Order of Columns in a Table ................................. 1650A.7.3. TEMPORARY TABLE Problems ...................................................... 1651

    A.8. Known Issues in MySQL .......................................................................... 1651A.8.1. Open Issues in MySQL .................................................................. 1651

    B. Error Codes and Messages ................................................................................... 1655B.1. Server Error Codes and Messages ............................................................... 1655B.2. Client Error Codes and Messages ................................................................ 1687

    C. Credits ............................................................................................................. 1692C.1. Developers at MySQL AB ......................................................................... 1692C.2. Contributors to MySQL ............................................................................ 1697C.3. Documenters and translators ...................................................................... 1702C.4. Libraries used by and included with MySQL ................................................. 1703C.5. Packages that support MySQL ................................................................... 1704C.6. Tools that were used to create MySQL ......................................................... 1704C.7. Supporters of MySQL .............................................................................. 1705

    D. MySQL Change History ...................................................................................... 1706D.1. Changes in release 5.0.x (Production) .......................................................... 1706

    D.1.1. Changes in release 5.0.25 (Not yet released) ....................................... 1707D.1.2. Changes in release 5.0.24 (Not yet released) ....................................... 1710D.1.3. Changes in release 5.0.23 (Not released) ............................................ 1711D.1.4. Changes in release 5.0.22 (24 May 2006) ........................................... 1721D.1.5. Changes in release 5.0.21 (02 May 2006) ........................................... 1722D.1.6. Changes in release 5.0.20a (18 April 2006) ........................................ 1727D.1.7. Changes in release 5.0.20 (31 March 2006) ........................................ 1728D.1.8. Changes in release 5.0.19 (04 March 2006) ........................................ 1732D.1.9. Changes in release 5.0.18 (21 December 2005) ................................... 1740D.1.10. Changes in release 5.0.17 (14 December 2005) ................................. 1742D.1.11. Changes in release 5.0.16 (10 November 2005) ................................. 1748D.1.12. Changes in release 5.0.15 (19 October 2005: Production) .................... 1753D.1.13. Changes in release 5.0.14 (Not released) .......................................... 1756D.1.14. Changes in release 5.0.13 (22 September 2005: Release Candidate) ...... 1759D.1.15. Changes in release 5.0.12 (02 September 2005) ................................. 1765D.1.16. Changes in release 5.0.11 (06 August 2005) ..................................... 1771D.1.17. Changes in release 5.0.10 (27 July 2005) ......................................... 1773D.1.18. Changes in release 5.0.9 (15 July 2005) ........................................... 1777D.1.19. Changes in release 5.0.8 (Not released) ............................................ 1780D.1.20. Changes in release 5.0.7 (10 June 2005) ........................................... 1785D.1.21. Changes in release 5.0.6 (26 May 2005) ........................................... 1788D.1.22. Changes in release 5.0.5 (Not released) ............................................ 1793D.1.23. Changes in release 5.0.4 (16 April 2005) .......................................... 1796D.1.24. Changes in release 5.0.3 (23 March 2005: Beta) ................................ 1799D.1.25. Changes in release 5.0.2 (01 December 2004) ................................... 1810D.1.26. Changes in release 5.0.1 (27 July 2004) ........................................... 1813D.1.27. Changes in release 5.0.0 (22 December 2003: Alpha) ......................... 1817

    D.2. Changes in MySQL Cluster ....................................................................... 1818D.2.1. Changes in MySQL Cluster-5.0.7 (10 June 2005) ................................ 1818D.2.2. Changes in MySQL Cluster-5.0.6 (26 May 2005) ................................ 1819D.2.3. Changes in MySQL Cluster-5.0.5 (Not released) ................................. 1819D.2.4. Changes in MySQL Cluster-5.0.4 (16 April 2005) ............................... 1820D.2.5. Changes in MySQL Cluster-5.0.3 (23 March 2005: Beta) ..................... 1820

    MySQL 5.0 Reference Manual

    xvii

  • D.2.6. Changes in MySQL Cluster-5.0.1 (27 July 2004) ................................ 1820D.2.7. Changes in MySQL Cluster-4.1.13 (15 July 2005) ............................... 1821D.2.8. Changes in MySQL Cluster-4.1.12 (13 May 2005) .............................. 1821D.2.9. Changes in MySQL Cluster-4.1.11 (01 April 2005) ............................. 1822D.2.10. Changes in MySQL Cluster-4.1.10 (12 February 2005) ....................... 1823D.2.11. Changes in MySQL Cluster-4.1.9 (13 January 2005) .......................... 1824D.2.12. Changes in MySQL Cluster-4.1.8 (14 December 2004) ....................... 1824D.2.13. Changes in MySQL Cluster-4.1.7 (23 October 2004) .......................... 1827D.2.14. Changes in MySQL Cluster-4.1.6 (10 October 2004) .......................... 1827D.2.15. Changes in MySQL Cluster-4.1.5 (16 September 2004) ...................... 1828D.2.16. Changes in MySQL Cluster-4.1.4 (31 August 2004) ........................... 1830D.2.17. Changes in MySQL Cluster-4.1.3 (28 June 2004) .............................. 1830

    D.3. MySQL Connector/ODBC (MyODBC) Change History ................................. 1831D.3.1. Changes in MyODBC 3.51.13 ......................................................... 1831D.3.2. Changes in MyODBC 3.51.12 ......................................................... 1831D.3.3. Changes in MyODBC 3.51.11 ......................................................... 1831

    D.4. MySQL Connector/NET Change History ..................................................... 1832D.4.1. Version 1.0.8 ................................................................................ 1832D.4.2. Version 1.0.7 ................................................................................ 1832D.4.3. Version 1.0.6 ................................................................................ 1833D.4.4. Version 1.0.5 ................................................................................ 1833D.4.5. Version 1.0.4 1-20-05 .................................................................... 1834D.4.6. Version 1.0.3-gamma 12-10-04 ........................................................ 1834D.4.7. Version 1.0.2-gamma 04-11-15 ........................................................ 1835D.4.8. Version 1.0.1-beta2 04-10-27 .......................................................... 1836D.4.9. Version 1.0.0 04-09-01 .................................................................. 1837D.4.10. Version 0.9.0 04-08-30 ................................................................. 1838D.4.11. Version 0.76 ............................................................................... 1841D.4.12. Version 0.75 ............................................................................... 1842D.4.13. Version 0.74 ............................................................................... 1843D.4.14. Version 0.71 ............................................................................... 1845D.4.15. Version 0.70 ............................................................................... 1845D.4.16. Version 0.68 ............................................................................... 1847D.4.17. Version 0.65 ............................................................................... 1848D.4.18. Version 0.60 ............................................................................... 1848D.4.19. Version 0.50 ............................................................................... 1848

    E. Porting to Other Systems ..................................................................................... 1849E.1. Debugging a MySQL Server ...................................................................... 1850

    E.1.1. Compiling MySQL for Debugging .................................................... 1850E.1.2. Creating Trace Files ....................................................................... 1851E.1.3. Debugging mysqld under gdb ....................................................... 1851E.1.4. Using a Stack Trace ....................................................................... 1853E.1.5. Using Server Logs to Find Causes of Errors in mysqld ....................... 1854E.1.6. Making a Test Case If You Experience Table Corruption ...................... 1854

    E.2. Debugging a MySQL Client ....................................................................... 1855E.3. The DBUG Package ................................................................................. 1855E.4. Comments about RTS Threads ................................................................... 1857E.5. Differences Between Thread Packages ......................................................... 1858

    F. Environment Variables ........................................................................................ 1859G. Regular Expressions ........................................................................................... 1860H. Limits in MySQL ............................................................................................... 1864

    H.1. Limits of Joins ........................................................................................ 1864I. Feature Restrictions ............................................................................................. 1865

    I.1. Restrictions on Stored Routines and Triggers ................................................. 1865I.2. Restrictions on Server-Side Cursors .............................................................. 1866I.3. Restrictions on Subqueries .......................................................................... 1867I.4. Restrictions on Views ................................................................................ 1870I.5. Restrictions on XA Transactions .................................................................. 1871

    MySQL 5.0 Reference Manual

    xviii

  • J. GNU General Public License ................................................................................. 1873K. MySQL FLOSS License Exception ....................................................................... 1878Index ................................................................................................................... 1881

    MySQL 5.0 Reference Manual

    xix

  • List of Tables15.1. Steps for Cluster rolling upgrades by upgrade type ..................................................

    xx

  • List of Examples23.1. Obtaining a Connection From the DriverManager ............................................ 150823.2. Using java.sql.Statement to Execute a SELECT Query .......................................... 150923.3. Stored Procedure Example ............................................................................... 150923.4. Using Connection.prepareCall() .......................................................... 151023.5. Registering Output Parameters .......................................................................... 151023.6. Setting CallableStatement Input Parameters ............................................... 151123.7. Retrieving Results and Output Parameter Values .................................................. 151223.8. Retrieving AUTO_INCREMENT Column Values using State-ment.getGeneratedKeys() .........................................................