Mysql 8.0 en 1 30
Mysql 8.0 en 1 30
0 Reference Manual
Including MySQL NDB Cluster 8.0
Abstract
This is the MySQL Reference Manual. It documents MySQL 8.0 through 8.0.37, as well as NDB Cluster releases
based on version 8.0 of NDB through 8.0.35-ndb-8.0.35, respectively. It may include documentation of features of
MySQL versions that have not yet been released. For information about which versions have been released, see the
MySQL 8.0 Release Notes.
MySQL 8.0 features. This manual describes features that are not included in every edition of MySQL 8.0; such
features may not be included in the edition of MySQL 8.0 licensed to you. If you have any questions about the
features included in your edition of MySQL 8.0, refer to your MySQL 8.0 license agreement or contact your Oracle
sales representative.
For notes detailing the changes in each release, see the MySQL 8.0 Release Notes.
For legal information, including licensing information, see the Preface and Legal Notices.
For help with using MySQL, please visit the MySQL Forums, where you can discuss your issues with other MySQL
users.
iii
MySQL 8.0 Reference Manual
iv
MySQL 8.0 Reference Manual
v
MySQL 8.0 Reference Manual
vi
MySQL 8.0 Reference Manual
vii
MySQL 8.0 Reference Manual
viii
MySQL 8.0 Reference Manual
ix
MySQL 8.0 Reference Manual
x
MySQL 8.0 Reference Manual
12.3.6 Character String Literal Character Set and Collation ............................................. 2240
12.3.7 The National Character Set ................................................................................ 2241
12.3.8 Character Set Introducers ................................................................................... 2242
12.3.9 Examples of Character Set and Collation Assignment .......................................... 2244
12.3.10 Compatibility with Other DBMSs ........................................................................ 2245
12.4 Connection Character Sets and Collations ..................................................................... 2245
12.5 Configuring Application Character Set and Collation ....................................................... 2251
12.6 Error Message Character Set ........................................................................................ 2253
12.7 Column Character Set Conversion ................................................................................. 2254
12.8 Collation Issues ............................................................................................................ 2255
12.8.1 Using COLLATE in SQL Statements ................................................................... 2255
12.8.2 COLLATE Clause Precedence ............................................................................ 2256
12.8.3 Character Set and Collation Compatibility ............................................................ 2256
12.8.4 Collation Coercibility in Expressions .................................................................... 2256
12.8.5 The binary Collation Compared to _bin Collations ................................................ 2258
12.8.6 Examples of the Effect of Collation ..................................................................... 2261
12.8.7 Using Collation in INFORMATION_SCHEMA Searches ........................................ 2262
12.9 Unicode Support ........................................................................................................... 2264
12.9.1 The utf8mb4 Character Set (4-Byte UTF-8 Unicode Encoding) .............................. 2266
12.9.2 The utf8mb3 Character Set (3-Byte UTF-8 Unicode Encoding) .............................. 2267
12.9.3 The utf8 Character Set (Deprecated alias for utf8mb3) ......................................... 2268
12.9.4 The ucs2 Character Set (UCS-2 Unicode Encoding) ............................................ 2268
12.9.5 The utf16 Character Set (UTF-16 Unicode Encoding) ........................................... 2268
12.9.6 The utf16le Character Set (UTF-16LE Unicode Encoding) .................................... 2269
12.9.7 The utf32 Character Set (UTF-32 Unicode Encoding) ........................................... 2269
12.9.8 Converting Between 3-Byte and 4-Byte Unicode Character Sets ........................... 2270
12.10 Supported Character Sets and Collations ..................................................................... 2272
12.10.1 Unicode Character Sets .................................................................................... 2273
12.10.2 West European Character Sets ......................................................................... 2281
12.10.3 Central European Character Sets ...................................................................... 2282
12.10.4 South European and Middle East Character Sets ............................................... 2283
12.10.5 Baltic Character Sets ........................................................................................ 2284
12.10.6 Cyrillic Character Sets ...................................................................................... 2284
12.10.7 Asian Character Sets ........................................................................................ 2285
12.10.8 The Binary Character Set ................................................................................. 2289
12.11 Restrictions on Character Sets ..................................................................................... 2291
12.12 Setting the Error Message Language ........................................................................... 2291
12.13 Adding a Character Set ............................................................................................... 2292
12.13.1 Character Definition Arrays ............................................................................... 2294
12.13.2 String Collating Support for Complex Character Sets .......................................... 2294
12.13.3 Multi-Byte Character Support for Complex Character Sets .................................. 2295
12.14 Adding a Collation to a Character Set .......................................................................... 2295
12.14.1 Collation Implementation Types ......................................................................... 2296
12.14.2 Choosing a Collation ID .................................................................................... 2299
12.14.3 Adding a Simple Collation to an 8-Bit Character Set ........................................... 2300
12.14.4 Adding a UCA Collation to a Unicode Character Set ........................................... 2301
12.15 Character Set Configuration ......................................................................................... 2308
12.16 MySQL Server Locale Support ..................................................................................... 2309
13 Data Types .............................................................................................................................. 2315
13.1 Numeric Data Types ..................................................................................................... 2316
13.1.1 Numeric Data Type Syntax ................................................................................. 2316
13.1.2 Integer Types (Exact Value) - INTEGER, INT, SMALLINT, TINYINT, MEDIUMINT,
BIGINT ......................................................................................................................... 2320
13.1.3 Fixed-Point Types (Exact Value) - DECIMAL, NUMERIC ...................................... 2321
xi
MySQL 8.0 Reference Manual
xii
MySQL 8.0 Reference Manual
xiii
MySQL 8.0 Reference Manual
xiv
MySQL 8.0 Reference Manual
xv
MySQL 8.0 Reference Manual
xvi
MySQL 8.0 Reference Manual
17.8.12 Enabling Automatic Configuration for a Dedicated MySQL Server ........................ 3510
17.9 InnoDB Table and Page Compression ........................................................................... 3512
17.9.1 InnoDB Table Compression ................................................................................ 3513
17.9.2 InnoDB Page Compression ................................................................................. 3527
17.10 InnoDB Row Formats .................................................................................................. 3531
17.11 InnoDB Disk I/O and File Space Management .............................................................. 3537
17.11.1 InnoDB Disk I/O ............................................................................................... 3537
17.11.2 File Space Management ................................................................................... 3538
17.11.3 InnoDB Checkpoints ......................................................................................... 3540
17.11.4 Defragmenting a Table ..................................................................................... 3540
17.11.5 Reclaiming Disk Space with TRUNCATE TABLE ............................................... 3541
17.12 InnoDB and Online DDL .............................................................................................. 3541
17.12.1 Online DDL Operations ..................................................................................... 3542
17.12.2 Online DDL Performance and Concurrency ........................................................ 3558
17.12.3 Online DDL Space Requirements ...................................................................... 3562
17.12.4 Online DDL Memory Management ..................................................................... 3562
17.12.5 Configuring Parallel Threads for Online DDL Operations ..................................... 3563
17.12.6 Simplifying DDL Statements with Online DDL .................................................... 3563
17.12.7 Online DDL Failure Conditions .......................................................................... 3564
17.12.8 Online DDL Limitations ..................................................................................... 3564
17.13 InnoDB Data-at-Rest Encryption .................................................................................. 3565
17.14 InnoDB Startup Options and System Variables ............................................................. 3574
17.15 InnoDB INFORMATION_SCHEMA Tables .................................................................... 3670
17.15.1 InnoDB INFORMATION_SCHEMA Tables about Compression ........................... 3670
17.15.2 InnoDB INFORMATION_SCHEMA Transaction and Locking Information ............. 3672
17.15.3 InnoDB INFORMATION_SCHEMA Schema Object Tables ................................. 3679
17.15.4 InnoDB INFORMATION_SCHEMA FULLTEXT Index Tables .............................. 3685
17.15.5 InnoDB INFORMATION_SCHEMA Buffer Pool Tables ........................................ 3688
17.15.6 InnoDB INFORMATION_SCHEMA Metrics Table ............................................... 3693
17.15.7 InnoDB INFORMATION_SCHEMA Temporary Table Info Table .......................... 3702
17.15.8 Retrieving InnoDB Tablespace Metadata from INFORMATION_SCHEMA.FILES .. 3703
17.16 InnoDB Integration with MySQL Performance Schema .................................................. 3705
17.16.1 Monitoring ALTER TABLE Progress for InnoDB Tables Using Performance
Schema ........................................................................................................................ 3707
17.16.2 Monitoring InnoDB Mutex Waits Using Performance Schema .............................. 3708
17.17 InnoDB Monitors ......................................................................................................... 3712
17.17.1 InnoDB Monitor Types ...................................................................................... 3713
17.17.2 Enabling InnoDB Monitors ................................................................................ 3713
17.17.3 InnoDB Standard Monitor and Lock Monitor Output ............................................ 3715
17.18 InnoDB Backup and Recovery ..................................................................................... 3719
17.18.1 InnoDB Backup ................................................................................................ 3719
17.18.2 InnoDB Recovery ............................................................................................. 3720
17.19 InnoDB and MySQL Replication ................................................................................... 3723
17.20 InnoDB memcached Plugin .......................................................................................... 3725
17.20.1 Benefits of the InnoDB memcached Plugin ........................................................ 3725
17.20.2 InnoDB memcached Architecture ...................................................................... 3726
17.20.3 Setting Up the InnoDB memcached Plugin ........................................................ 3728
17.20.4 InnoDB memcached Multiple get and Range Query Support ............................... 3733
17.20.5 Security Considerations for the InnoDB memcached Plugin ................................ 3736
17.20.6 Writing Applications for the InnoDB memcached Plugin ...................................... 3738
17.20.7 The InnoDB memcached Plugin and Replication ................................................ 3750
17.20.8 InnoDB memcached Plugin Internals ................................................................. 3754
17.20.9 Troubleshooting the InnoDB memcached Plugin ................................................ 3759
17.21 InnoDB Troubleshooting .............................................................................................. 3761
xvii
MySQL 8.0 Reference Manual
xviii
MySQL 8.0 Reference Manual
xix
MySQL 8.0 Reference Manual
xx
MySQL 8.0 Reference Manual
xxi
MySQL 8.0 Reference Manual
25.6.12 Online Operations with ALTER TABLE in NDB Cluster ....................................... 4975
25.6.13 Privilege Synchronization and NDB_STORED_USER ......................................... 4979
25.6.14 File System Encryption for NDB Cluster ............................................................ 4980
25.6.15 NDB API Statistics Counters and Variables ........................................................ 4983
25.6.16 ndbinfo: The NDB Cluster Information Database ................................................ 4995
25.6.17 INFORMATION_SCHEMA Tables for NDB Cluster ............................................. 5089
25.6.18 NDB Cluster and the Performance Schema ....................................................... 5090
25.6.19 Quick Reference: NDB Cluster SQL Statements ................................................ 5091
25.6.20 NDB Cluster Security Issues ............................................................................. 5098
25.7 NDB Cluster Replication ................................................................................................ 5105
25.7.1 NDB Cluster Replication: Abbreviations and Symbols ........................................... 5107
25.7.2 General Requirements for NDB Cluster Replication .............................................. 5108
25.7.3 Known Issues in NDB Cluster Replication ............................................................ 5109
25.7.4 NDB Cluster Replication Schema and Tables ...................................................... 5117
25.7.5 Preparing the NDB Cluster for Replication ........................................................... 5124
25.7.6 Starting NDB Cluster Replication (Single Replication Channel) .............................. 5127
25.7.7 Using Two Replication Channels for NDB Cluster Replication ............................... 5129
25.7.8 Implementing Failover with NDB Cluster Replication ............................................ 5130
25.7.9 NDB Cluster Backups With NDB Cluster Replication ............................................ 5131
25.7.10 NDB Cluster Replication: Bidirectional and Circular Replication ........................... 5138
25.7.11 NDB Cluster Replication Using the Multithreaded Applier .................................... 5143
25.7.12 NDB Cluster Replication Conflict Resolution ...................................................... 5146
25.8 NDB Cluster Release Notes .......................................................................................... 5164
26 Partitioning .............................................................................................................................. 5167
26.1 Overview of Partitioning in MySQL ................................................................................. 5168
26.2 Partitioning Types ......................................................................................................... 5171
26.2.1 RANGE Partitioning ............................................................................................ 5173
26.2.2 LIST Partitioning ................................................................................................. 5177
26.2.3 COLUMNS Partitioning ....................................................................................... 5179
26.2.4 HASH Partitioning .............................................................................................. 5187
26.2.5 KEY Partitioning ................................................................................................. 5190
26.2.6 Subpartitioning ................................................................................................... 5192
26.2.7 How MySQL Partitioning Handles NULL .............................................................. 5193
26.3 Partition Management ................................................................................................... 5198
26.3.1 Management of RANGE and LIST Partitions ........................................................ 5199
26.3.2 Management of HASH and KEY Partitions .......................................................... 5205
26.3.3 Exchanging Partitions and Subpartitions with Tables ............................................ 5206
26.3.4 Maintenance of Partitions ................................................................................... 5214
26.3.5 Obtaining Information About Partitions ................................................................. 5215
26.4 Partition Pruning ........................................................................................................... 5217
26.5 Partition Selection ......................................................................................................... 5220
26.6 Restrictions and Limitations on Partitioning ..................................................................... 5226
26.6.1 Partitioning Keys, Primary Keys, and Unique Keys ............................................... 5232
26.6.2 Partitioning Limitations Relating to Storage Engines ............................................. 5236
26.6.3 Partitioning Limitations Relating to Functions ....................................................... 5237
27 Stored Objects ......................................................................................................................... 5239
27.1 Defining Stored Programs ............................................................................................. 5240
27.2 Using Stored Routines .................................................................................................. 5241
27.2.1 Stored Routine Syntax ........................................................................................ 5242
27.2.2 Stored Routines and MySQL Privileges ............................................................... 5242
27.2.3 Stored Routine Metadata .................................................................................... 5243
27.2.4 Stored Procedures, Functions, Triggers, and LAST_INSERT_ID() ......................... 5243
27.3 Using Triggers .............................................................................................................. 5244
27.3.1 Trigger Syntax and Examples ............................................................................. 5244
xxii
MySQL 8.0 Reference Manual
xxiii
MySQL 8.0 Reference Manual
xxiv
MySQL 8.0 Reference Manual
xxv
MySQL 8.0 Reference Manual
xxvi
MySQL 8.0 Reference Manual
xxvii
xxviii
Preface and Legal Notices
This is the Reference Manual for the MySQL Database System, version 8.0, through release 8.0.36.
Differences between minor versions of MySQL 8.0 are noted in the present text with reference to release
numbers (8.0.x). For license information, see the Legal Notices.
This manual is not intended for use with older versions of the MySQL software due to the many functional
and other differences between MySQL 8.0 and previous versions. If you are using an earlier release of
the MySQL software, please refer to the appropriate manual. For example, MySQL 5.7 Reference Manual
covers the 5.7 series of MySQL software releases.
Licensing information—MySQL 8.0. This product may include third-party software, used under
license. If you are using a Commercial release of MySQL 8.0, see the MySQL 8.0 Commercial Release
License Information User Manual for licensing information, including licensing information relating to third-
party software that may be included in this Commercial release. If you are using a Community release
of MySQL 8.0, see the MySQL 8.0 Community Release License Information User Manual for licensing
information, including licensing information relating to third-party software that may be included in this
Community release.
Licensing information—MySQL NDB Cluster 8.0. If you are using a Commercial release of MySQL
NDB Cluster 8.0, see the MySQL NDB Cluster 8.0 Commercial Release License Information User Manual
for licensing information, including licensing information relating to third-party software that may be
included in this Commercial release. If you are using a Community release of MySQL NDB Cluster 8.0,
see the MySQL NDB Cluster 8.0 Community Release License Information User Manual for licensing
information, including licensing information relating to third-party software that may be included in this
Community release.
Legal Notices
Copyright © 1997, 2024, Oracle and/or its affiliates.
License Restrictions
This software and related documentation are provided under a license agreement containing restrictions
on use and disclosure and are protected by intellectual property laws. Except as expressly permitted
in your license agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast,
modify, license, transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any
means. Reverse engineering, disassembly, or decompilation of this software, unless required by law for
interoperability, is prohibited.
Warranty Disclaimer
The information contained herein is subject to change without notice and is not warranted to be error-free.
If you find any errors, please report them to us in writing.
If this is software, software documentation, data (as defined in the Federal Acquisition Regulation), or
related documentation that is delivered to the U.S. Government or anyone licensing it on behalf of the U.S.
Government, then the following notice is applicable:
U.S. GOVERNMENT END USERS: Oracle programs (including any operating system, integrated
software, any programs embedded, installed, or activated on delivered hardware, and modifications
of such programs) and Oracle computer documentation or other Oracle data delivered to or accessed
by U.S. Government end users are "commercial computer software," "commercial computer software
documentation," or "limited rights data" pursuant to the applicable Federal Acquisition Regulation and
xxix
Documentation Accessibility
agency-specific supplemental regulations. As such, the use, reproduction, duplication, release, display,
disclosure, modification, preparation of derivative works, and/or adaptation of i) Oracle programs (including
any operating system, integrated software, any programs embedded, installed, or activated on delivered
hardware, and modifications of such programs), ii) Oracle computer documentation and/or iii) other Oracle
data, is subject to the rights and limitations specified in the license contained in the applicable contract.
The terms governing the U.S. Government's use of Oracle cloud services are defined by the applicable
contract for such services. No other rights are granted to the U.S. Government.
This software or hardware is developed for general use in a variety of information management
applications. It is not developed or intended for use in any inherently dangerous applications, including
applications that may create a risk of personal injury. If you use this software or hardware in dangerous
applications, then you shall be responsible to take all appropriate fail-safe, backup, redundancy, and other
measures to ensure its safe use. Oracle Corporation and its affiliates disclaim any liability for any damages
caused by use of this software or hardware in dangerous applications.
Trademark Notice
Oracle, Java, MySQL, and NetSuite are registered trademarks of Oracle and/or its affiliates. Other names
may be trademarks of their respective owners.
Intel and Intel Inside are trademarks or registered trademarks of Intel Corporation. All SPARC trademarks
are used under license and are trademarks or registered trademarks of SPARC International, Inc. AMD,
Epyc, and the AMD logo are trademarks or registered trademarks of Advanced Micro Devices. UNIX is a
registered trademark of The Open Group.
This software or hardware and documentation may provide access to or information about content,
products, and services from third parties. Oracle Corporation and its affiliates are not responsible for and
expressly disclaim all warranties of any kind with respect to third-party content, products, and services
unless otherwise set forth in an applicable agreement between you and Oracle. Oracle Corporation and its
affiliates will not be responsible for any loss, costs, or damages incurred due to your access to or use of
third-party content, products, or services, except as set forth in an applicable agreement between you and
Oracle.
This documentation is NOT distributed under a GPL license. Use of this documentation is subject to the
following terms:
You may create a printed copy of this documentation solely for your own personal use. Conversion to other
formats is allowed as long as the actual content is not altered or edited in any way. You shall not publish
or distribute this documentation in any form or on any media, except if you distribute the documentation in
a manner similar to how Oracle disseminates it (that is, electronically for download on a Web site with the
software) or on a CD-ROM or similar medium, provided however that the documentation is disseminated
together with the software on the same medium. Any other use, such as any dissemination of printed
copies or use of this documentation, in whole or in part, in another publication, requires the prior written
consent from an authorized representative of Oracle. Oracle and/or its affiliates reserve any and all rights
to this documentation not expressly granted above.
Documentation Accessibility
For information about Oracle's commitment to accessibility, visit the Oracle Accessibility Program website
at
xxx