当前位置:网站首页>Compatibility comparison between tidb and MySQL
Compatibility comparison between tidb and MySQL
2022-06-27 06:34:00 【Tianxiang shop】
TiDB Highly compatible MySQL 5.7 agreement 、MySQL 5.7 Common functions and grammar .MySQL 5.7 System tools in Ecology (PHPMyAdmin、Navicat、MySQL Workbench、mysqldump、Mydumper/Myloader)、 Clients and so on are suitable for TiDB.
but TiDB Some... Are not yet supported MySQL function , The possible reasons are as follows :
- There's a better solution , for example JSON replace XML function .
- At present, the demand for these functions is not high , For example, storing processes and functions .
- It is difficult to implement some functions on distributed systems .
in addition to ,TiDB I won't support it MySQL Copy agreement , However, special tools are provided for MySQL Copy the data
- from MySQL Copy :TiDB Data Migration (DM) Yes, it will MySQL/MariaDB Data migration to TiDB Tools for , Can be used for incremental data replication .
- towards MySQL Copy :TiCDC It's a pull through TiKV The change log implements TiDB Incremental data synchronization tool , It can be done by MySQL sink take TiDB Incremental data is copied to MySQL.
Be careful
This page only covers MySQL And TiDB The overall difference . About Safety features 、 Pessimistic transaction mode For relevant compatibility information, please refer to their specific pages .
Unsupported features
- Stored procedures and functions
- trigger
- event
- Custom function
- Foreign key constraints #18209
- Full text syntax and indexing #1793
- Functions of space type ( namely
GIS/GEOMETRY)、 Data types and indexes #6347 - Not
ascii、latin1、binary、utf8、utf8mb4、gbkCharacter set for - SYS schema
- MySQL Tracking optimizer
- XML function
- X-Protocol #1109
- Savepoints #6840
- Column level permissions #9766
XAgrammar (TiDB Internal use of two-phase commit , But it didn't pass SQL Interface disclosure )CREATE TABLE tblName AS SELECT stmtgrammar #4754CHECK TABLEgrammar #4673CHECKSUM TABLEgrammar #1895REPAIR TABLEgrammarOPTIMIZE TABLEgrammarHANDLERsentenceCREATE TABLESPACEsentence
And MySQL A detailed description of the different features
Self increasing ID
TiDB The self incrementing column of can guarantee the uniqueness , It can also ensure that in a single TiDB server Self increasing in China , But there is no guarantee that there will be more TiDB server Self increasing in China , Continuity of automatically assigned values is not guaranteed . Mixing default values with custom values is not recommended , If mixed, you may receive
Duplicated ErrorError messages for .TiDB It can be done by
tidb_allow_remove_auto_incThe system variable turns on or off... That allows columns to be removedAUTO_INCREMENTattribute . The syntax for deleting column attributes is :ALTER TABLE MODIFYorALTER TABLE CHANGE.TiDB Adding columns is not supported
AUTO_INCREMENTattribute , After removing this attribute, it cannot be recovered .
Self increasing ID For details, please refer to AUTO_INCREMENT.
Be careful
If no primary key is specified when creating a table ,TiDB Will use _tidb_rowid To identify lines , This value will be allocated and auto incremented ( If it exists ) Share one distributor . If the auto increment column is specified as the primary key , be TiDB This column will be used to identify rows . So there are the following example cases :
mysql> CREATE TABLE t(id INT UNIQUE KEY AUTO_INCREMENT); Query OK, 0 rows affected (0.05 sec) mysql> INSERT INTO t VALUES(),(),(); Query OK, 3 rows affected (0.00 sec) Records: 3 Duplicates: 0 Warnings: 0 mysql> SELECT _tidb_rowid, id FROM t; +-------------+------+ | _tidb_rowid | id | +-------------+------+ | 4 | 1 | | 5 | 2 | | 6 | 3 | +-------------+------+ 3 rows in set (0.01 sec)
Be careful
Use AUTO_INCREMENT It may bring hot issues to the production environment , Therefore, it is recommended to use AUTO_RANDOM Instead of . Please refer to TiDB Dealing with hot issues .
Performance schema
TiDB The main use of Prometheus and Grafana To store and query relevant performance monitoring indicators , therefore Performance schema Some tables are empty .
Query plan
EXPLAIN/EXPLAIN FOR Output format 、 Content 、 Permission settings and MySQL There is a big difference , See understand TiDB Implementation plan .
Built-in functions
Support common MySQL Built-in functions , Some functions do not support . Can be carried out by SHOW BUILTINS Statement to view available built-in functions . Reference resources SQL Grammar documents .
DDL The limitation of
TiDB in , All those who support DDL Changes are performed online . And MySQL comparison ,TiDB Medium DDL There are the following limitations :
Not in a single line
ALTER TABLEStatement . for example , You cannot add multiple columns or indexes to a single statement , otherwise , It may outputUnsupported multi schema changeError of .ALTER TABLEA few types of changes are not supported . such as ,TiDB No support fromDECIMALToDATEChanges . When an unsupported type change is encountered ,TiDB Will reportUnsupported modify column: type %d not match origin %dError of . For more details , Please refer to ALTER TABLE.TiDB in ,
ALGORITHM={INSTANT,INPLACE,COPY}Syntax is only used as a way to specify , Do not changeALTERAlgorithm , For details, please refer to ALTER TABLE.Adding or deleting... Is not supported
CLUSTEREDPrimary key of type . To learn aboutCLUSTEREDDetails of the primary key , Please refer to Cluster index .Specifying different types of indexes... Is not supported (
HASH|BTREE|RTREE|FULLTEXT). If different types of indexes are specified ,TiDB These indexes are parsed and ignored .Partition table support
HASH、RANGEandLISTPartition type . For unsupported partition types ,TiDB May reportWarning: Unsupported partition type %s, treat as normal tableerror , among%sIs a specific partition type that is not supported .Partition tables also support
ADD、DROP、TRUNCATEoperation . Other partition operations are ignored .TiDB The following partition table syntax is not supported :PARTITION BY KEYSUBPARTITION{CHECK|TRUNCATE|OPTIMIZE|REPAIR|IMPORT|DISCARD|REBUILD|REORGANIZE|COALESCE} PARTITION
For more details , Please refer to Partition table document .
ANALYZE TABLE
TiDB Medium Information Statistics And MySQL There's a difference in :TiDB The information statistics in will completely reconstruct the statistics of the table , The statement execution process is long , But in MySQL/InnoDB in , It is a lightweight statement , The execution process is short .
For more information on statistical differences, see ANALYZE TABLE.
SELECT The limitation of
- I won't support it
SELECT ... INTO @ Variablegrammar . - I won't support it
SELECT ... GROUP BY ... WITH ROLLUPgrammar . - TiDB Medium
SELECT .. GROUP BY exprThe return result of and MySQL 5.7 Don't agree with each other .MySQL 5.7 The result is equivalent toGROUP BY expr ORDER BY expr.
For details, see SELECT.
UPDATE sentence
For details, see UPDATE.
View
TiDB Views in are not updatable , I won't support it UPDATE、INSERT、DELETE Wait for write operation .
A temporary table
See TiDB Local temporary tables and MySQL Compatibility of temporary tables .
Character set and collation
About TiDB Support for character sets and collations , See Character set and collation .
About GBK Character set and MySQL Compatibility of , See GBK Compatible with the situation .
TiDB Inherit the character set used in the table as the national character set .
Storage engine
- Specify the storage engine only if it is syntactically compatible when creating tables , actually TiDB The meta information will be uniformly described as InnoDB Storage engine .TiDB Support similar MySQL Storage engine abstraction , But it needs to be passed when the system is started --store Configuration item to specify the storage engine .
SQL Pattern
TiDB Support most SQL Pattern . Don't support SQL The pattern is as follows :
- Compatibility mode is not supported , for example :
OracleandPostgreSQL(TiDB Resolve but ignore these two compatibility modes ),MySQL 5.7 Compatibility mode deprecated ,MySQL 8.0 Compatibility mode removed . - TiDB Of
ONLY_FULL_GROUP_BYPatterns and MySQL 5.7 There are subtle Semantic difference . NO_DIR_IN_CREATEandNO_ENGINE_SUBSTITUTIONIt is only used to solve problems related to MySQL Compatibility problem , It doesn't apply to TiDB.
default setting
Character set :
- TiDB Default :
utf8mb4. - MySQL 5.7 Default :
latin1. - MySQL 8.0 Default :
utf8mb4.
- TiDB Default :
Sort rule :
- TiDB in
utf8mb4Character set default :utf8mb4_bin. - MySQL 5.7 in
utf8mb4Character set default :utf8mb4_general_ci. - MySQL 8.0 in
utf8mb4Character set default :utf8mb4_0900_ai_ci.
- TiDB in
foreign_key_checks:- TiDB Default :
OFF, It only supports setting this value toOFF. - MySQL 5.7 Default :
ON.
- TiDB Default :
SQL mode:
- TiDB Default :
ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION. - MySQL 5.7 Default and TiDB identical .
- MySQL 8.0 Default
ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION.
- TiDB Default :
lower_case_table_names:- TiDB Default :
2, It only supports setting this value to2. - MySQL The default is as follows :
- Linux The value in the system is
0 - Windows The value in the system is
1 - macOS The value in the system is
2
- Linux The value in the system is
- TiDB Default :
explicit_defaults_for_timestamp:- TiDB Default :
ON, It only supports setting this value toON. - MySQL 5.7 Default :
OFF. - MySQL 8.0 Default :
ON.
- TiDB Default :
The difference between date and time processing
The time zone
TiDB All time zone rules currently installed in the system are used for calculation ( It's usually
tzdatapackage ), All time zone names can be used without importing time zone table data , Calculation rules cannot be modified by importing time zone table data .MySQL Local time zone is used by default , It depends on the current time zone rules built into the system ( For example, when does daylight saving time begin ) Calculate ; And before Import time zone table data The time zone cannot be specified by the time zone name .
Type system
I won't support it FLOAT4/FLOAT8.
I won't support it
SQL_TSI_*( IncludeSQL_TSI_MONTH、SQL_TSI_WEEK、SQL_TSI_DAY、SQL_TSI_HOUR、SQL_TSI_MINUTEandSQL_TSI_SECOND, But does not includeSQL_TSI_YEAR).
MySQL Incompatibilities caused by deprecated features
TiDB I won't support it MySQL Features marked as deprecated in , Include :
- Specify the precision of the floating point type .MySQL 8.0 Abandoning With this function , It is suggested to use it instead
DECIMALtype . ZEROFILLattribute . MySQL 8.0 Abandoning With this function , It is recommended to fill in digital values in business applications .
边栏推荐
- JVM整体结构解析
- JVM garbage collection mechanism
- 美摄云服务方案:专为轻量化视频制作场景打造
- Kubesphere cluster configuration NFS storage solution - favorite
- 426-二叉树(513.找树左下角的值、112. 路径总和、106.从中序与后序遍历序列构造二叉树、654. 最大二叉树)
- Assembly language - Wang Shuang Chapter 3 notes and experiments
- Dev++ environment setting C language keyword display color
- TiDB 中的SQL 基本操作
- HTAP 快速上手指南
- Sqlsever 字段相乘后保留2位小数
猜你喜欢

网关状态检测 echo request/reply

JVM的垃圾回收机制

POI 替换docx中的文字和图片

Assembly language - Wang Shuang Chapter 8 two basic problems in data processing - Notes

飞行器翼尖加速度和控制面的MPC控制

Active learning

Thinking technology: how to solve the dilemma in work and life?

Inter thread wait and wake-up mechanism, singleton mode, blocking queue, timer

Dev++ 环境设置C语言关键字显示颜色

Information System Project Manager - Chapter VII project cost management
随机推荐
One year's experience of technical personnel in Entrepreneurship
Instance tunnel use
Altium Designer 19 器件丝印标号位置批量统一摆放
JVM整体结构解析
[QT] use structure data to generate read / write configuration file code
HTAP 快速上手指南
JVM overall structure analysis
下载cuda和cudnn
2018年数学建模竞赛-高温作业专用服装设计
The form verifies the variables bound to the V-model, and the solution to invalid verification
Configuration of vscode korofileheader
winow10安装Nexus nexus-3.20.1-01
693. alternate bit binary number
分数阶PID控制
Code is data
Dev++ environment setting C language keyword display color
建模竞赛-光传送网建模与价值评估
快速实现单片机和手机蓝牙通信
多线程带来的的风险——线程安全
研究生数学建模竞赛-无人机在抢险救灾中的优化应用