当前位置:网站首页>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 .
边栏推荐
- 使用 WordPress快速个人建站指南
- Convolution neural network -- Application of CNN model (ore prospecting prediction)
- tar: /usr/local:归档中找不到tar: 由于前次错误,将以上次的错误状态退出
- TiDB的事务概览
- Us camera cloud service scheme: designed for lightweight video production scenes
- Redis 缓存穿透、缓存击穿、缓存雪崩
- TiDB 数据库快速上手指南
- 写一个 goroutine 实例, 同时练习一下 chan
- [getting started] regular expression Basics
- Dev++ 环境设置C语言关键字显示颜色
猜你喜欢

Crawler learning 5--- anti crawling identification picture verification code (ddddocr and pyteseract measured effect)

Fast realization of Bluetooth communication between MCU and mobile phone

Proxy-Reflect使用详解

G1 and ZGC garbage collector

yaml文件加密

路由器和交换机的区别

Caldera安装及简单使用

Multithreading basic Part3

Block level elements & inline elements

How to check the frequency of memory and the number of memory slots in CPU-Z?
随机推荐
C Primer Plus Chapter 11_ Strings and string functions_ Codes and exercises
第 299 场周赛 第四题 6103. 从树中删除边的最小分数
高斯分布Gaussian distribution、线性回归、逻辑回归logistics regression
On gpu: historical development and structure
使用 WordPress快速个人建站指南
快速实现蓝牙iBeacn功能详解
Once spark reported an error: failed to allocate a page (67108864 bytes), try again
Spark SQL common time functions
Functional continuous
Quick personal site building guide using WordPress
Fast realization of Bluetooth communication between MCU and mobile phone
Assembly language - Wang Shuang Chapter 11 flag register - Notes
Matlab quickly converts two-dimensional coordinates of images into longitude and latitude coordinates
TiDB的事务概览
浅谈GPU:历史发展,架构
TiDB 数据库快速上手指南
Cloud-Native Database Systems at Alibaba: Opportunities and Challenges
Assembly language - Wang Shuang Chapter 9 Principles of transfer instructions - Notes
Gaussian distribution, linear regression, logistic regression
Spark sql 常用时间函数