当前位置:网站首页>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
、gbk
Character set for - SYS schema
- MySQL Tracking optimizer
- XML function
- X-Protocol #1109
- Savepoints #6840
- Column level permissions #9766
XA
grammar (TiDB Internal use of two-phase commit , But it didn't pass SQL Interface disclosure )CREATE TABLE tblName AS SELECT stmt
grammar #4754CHECK TABLE
grammar #4673CHECKSUM TABLE
grammar #1895REPAIR TABLE
grammarOPTIMIZE TABLE
grammarHANDLER
sentenceCREATE TABLESPACE
sentence
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 Error
Error messages for .TiDB It can be done by
tidb_allow_remove_auto_inc
The system variable turns on or off... That allows columns to be removedAUTO_INCREMENT
attribute . The syntax for deleting column attributes is :ALTER TABLE MODIFY
orALTER TABLE CHANGE
.TiDB Adding columns is not supported
AUTO_INCREMENT
attribute , 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 TABLE
Statement . for example , You cannot add multiple columns or indexes to a single statement , otherwise , It may outputUnsupported multi schema change
Error of .ALTER TABLE
A few types of changes are not supported . such as ,TiDB No support fromDECIMAL
ToDATE
Changes . When an unsupported type change is encountered ,TiDB Will reportUnsupported modify column: type %d not match origin %d
Error 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 changeALTER
Algorithm , For details, please refer to ALTER TABLE.Adding or deleting... Is not supported
CLUSTERED
Primary key of type . To learn aboutCLUSTERED
Details 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
、RANGE
andLIST
Partition type . For unsupported partition types ,TiDB May reportWarning: Unsupported partition type %s, treat as normal table
error , among%s
Is a specific partition type that is not supported .Partition tables also support
ADD
、DROP
、TRUNCATE
operation . Other partition operations are ignored .TiDB The following partition table syntax is not supported :PARTITION BY KEY
SUBPARTITION
{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 @ Variable
grammar . - I won't support it
SELECT ... GROUP BY ... WITH ROLLUP
grammar . - TiDB Medium
SELECT .. GROUP BY expr
The 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 :
Oracle
andPostgreSQL
(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_BY
Patterns and MySQL 5.7 There are subtle Semantic difference . NO_DIR_IN_CREATE
andNO_ENGINE_SUBSTITUTION
It 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
utf8mb4
Character set default :utf8mb4_bin
. - MySQL 5.7 in
utf8mb4
Character set default :utf8mb4_general_ci
. - MySQL 8.0 in
utf8mb4
Character 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
tzdata
package ), 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_MINUTE
andSQL_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
DECIMAL
type . ZEROFILL
attribute . MySQL 8.0 Abandoning With this function , It is recommended to fill in digital values in business applications .
边栏推荐
- C Primer Plus Chapter 11_ Strings and string functions_ Codes and exercises
- 汇编语言-王爽 第11章 标志寄存器-笔记
- Program ape learning Tiktok short video production
- Information System Project Manager - Chapter VII project cost management
- LeetCode 0086.分隔链表
- Matlab quickly converts two-dimensional coordinates of images into longitude and latitude coordinates
- 【QT小记】QT中正则表达式QRegularExpression的基本使用
- LeetCode 0086. Separate linked list
- JVM garbage collection mechanism
- 快速实现蓝牙iBeacn功能详解
猜你喜欢
Fast realization of Bluetooth communication between MCU and mobile phone
Multithreading basic part2
Distribution gaussienne, régression linéaire, régression logistique
The restart status of the openstack instance will change to the error handling method. The openstack built by the container restarts the compute service method of the computing node and prompts the gi
Small program of C language practice (consolidate and deepen the understanding of knowledge points)
The fourth question of the 299th weekly match 6103 Minimum fraction of edges removed from the tree
Openresty usage document
Gaussian distribution, linear regression, logistic regression
Thinking technology: how to solve the dilemma in work and life?
LeetCode 0086. Separate linked list
随机推荐
Us camera cloud service scheme: designed for lightweight video production scenes
线程间等待与唤醒机制、单例模式、阻塞队列、定时器
Free SSH and telnet client putty
One year's experience of technical personnel in Entrepreneurship
汇编语言-王爽 第11章 标志寄存器-笔记
G1 and ZGC garbage collector
693. alternate bit binary number
Cloud-Native Database Systems at Alibaba: Opportunities and Challenges
记一次Spark报错:Failed to allocate a page (67108864 bytes), try again.
论文阅读技巧
使用 WordPress快速个人建站指南
Redis cache penetration, cache breakdown, cache avalanche
Distribution gaussienne, régression linéaire, régression logistique
Matlab quickly converts two-dimensional coordinates of images into longitude and latitude coordinates
Multithreading basic part part 1
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
飞行器翼尖加速度和控制面的MPC控制
310. minimum height tree
ORA-00909: 参数个数无效,concat引起
The form verifies the variables bound to the V-model, and the solution to invalid verification