当前位置:网站首页>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 .
边栏推荐
- Maxcompute SQL 的查询结果条数受限1W
- 【QT小记】QT中正则表达式QRegularExpression的基本使用
- Openresty usage document
- EasyExcel:读取Excel数据到List集合中
- 研究生数学建模竞赛-无人机在抢险救灾中的优化应用
- 分数阶PID控制
- How to check the frequency of memory and the number of memory slots in CPU-Z?
- 乐观事务和悲观事务
- vscode korofileheader 的配置
- An Empirical Evaluation of In-Memory Multi-Version Concurrency Control
猜你喜欢

分数阶PID控制

Free SSH and telnet client putty

G1和ZGC垃圾收集器

Assembly language - Wang Shuang Chapter 9 Principles of transfer instructions - Notes

Information System Project Manager - Chapter VII project cost management

第 299 场周赛 第四题 6103. 从树中删除边的最小分数

427-二叉树(617.合并二叉树、700.二叉搜索树中的搜索、98. 验证二叉搜索树、530.二叉搜索树的最小绝对差)

426 binary tree (513. find the value in the lower left corner of the tree, 112. sum of paths, 106. construct a binary tree from the middle order and post order traversal sequence, 654. maximum binary

快速实现蓝牙iBeacn功能详解

Using CSDN to develop cloud and build navigation websites
随机推荐
可扩展哈希
[QT dot] realize the watchdog function to detect whether the external program is running
Centos7.9安装mysql 5.7,并设置开机启动
The fourth question of the 299th weekly match 6103 Minimum fraction of edges removed from the tree
多线程带来的的风险——线程安全
Dev++ 环境设置C语言关键字显示颜色
2018年数学建模竞赛-高温作业专用服装设计
[getting started] regular expression Basics
第 299 场周赛 第四题 6103. 从树中删除边的最小分数
Distribution gaussienne, régression linéaire, régression logistique
Altium Designer 19 器件丝印标号位置批量统一摆放
What's new in redis4.0 - active memory defragmentation
主动学习(active learning)
One year's experience of technical personnel in Entrepreneurship
块级元素&行内元素
The SCP command is used in the expect script. The perfect solution to the problem that the SCP command in the expect script cannot obtain the value
【QT小点】QT下载链接
Dev++ environment setting C language keyword display color
[QT notes] basic use of qregularexpression in QT
【QT小记】QT中正则表达式QRegularExpression的基本使用