Compatibility comparison between TiDB and MySQL

  • TiDB supports the MySQL transport protocol and most of its syntax. This means that your existing MySQL connectors and clients will continue to work. In most cases, your existing applications can be migrated to TiDB without any code modification.
  • The current officially supported version of the TiDB server is MySQL 5.7. Most MySQL operation and maintenance tools (such as PHPMyAdmin, Navicat, MySQL Workbench, etc.), and backup and recovery tools (such as mysqldump, Mydumper/myloader) can be used directly.
  • However, because some features cannot be implemented well in a distributed environment, they are not supported for the time being or their performance is different from MySQL.
  • Some MySQL syntax can be parsed and passed in TiDB, but no subsequent processing will be done. For example, the Engine in the Create Table statement is parsed and ignored.

1 MySql features not supported by TiDB

  • stored procedures and functions
  • trigger
  • event
  • custom function
  • foreign key constraints
  • Temporary tables
  • Full-text/spatial functions and indexes
  • Character sets other than ascii / latin1 / binary / utf8 / utf8mb4
  • SYS schema
  • MySQL trace optimizer
  • XML functions
  • X-Protocol
  • Savepoints
  • column level permissions
  • XA syntax (TiDB uses two-phase commit internally, but it is not exposed through the SQL interface)
  • CREATE TABLE tblName AS SELECT stmt 语法
  • CHECK TABLE syntax
  • CHECKSUM TABLE syntax
  • GET_LOCK and RELEASE_LOCK functions

2 auto-increment ID

The auto-increment column of TiDB is only guaranteed to be unique, and it can also be guaranteed to be auto-incremented in a single TiDB server, but it is not guaranteed to be auto-incremented in multiple TiDB servers, and the continuity of automatically assigned values ​​is not guaranteed. It is recommended not to combine default values ​​with custom If the values ​​are mixed, DuplicatedError may be received.

TiDB can enable or disable the AUTO_INCREMENT property that allows column removal through tidb_allow_remove_auto_incsystem variables
. The syntax for dropping a column attribute is: alter table modify or alter table change.

TiDB does not support the AUTO_INCREMENT attribute of added columns, and it cannot be restored after removing this attribute.

3 Limitations of SELECT

  • SELECT ... INTO @variable syntax is not supported.
  • The SELECT ... GROUP BY ... WITH ROLLUP syntax is not supported.
  • The return result of SELECT ... GROUP BY expr in TiDB is not consistent with MySQL 5.7. The result for MySQL 5.7 is equivalent to GROUP BY expr ORDER BY expr. However, the results returned by this syntax in TiDB do not promise any order, which is consistent with the behavior of MySQL 8.0.

4 views

TiDB currently does not support writing operations such as UPDATE, INSERT, and DELETE on views.

5 Differences in default settings

5.1 Character set

TiDB default: utf8mb4 .
MySQL 5.7 default: latin1 .
MySQL 8.0 default: utf8mb4 .

5.2 Collation rules

Default utf8mb4 character set in TiDB: utf8mb4_bin .
Default utf8mb4 character set in MySQL 5.7: utf8mb4_general_ci .
Default utf8mb4 character set in MySQL 8.0: utf8mb4_0900_ai_ci .

5.3 Case sensitivity

Regarding the configuration of lower_case_table_names
TiDB default: 2, and only supports setting the value to 2.
The MySQL defaults are as follows:
In Linux system, the value is 0
In Windows system, the value is 1
In macOS system, the value is 2

Parameter explanation
lower_case_table_names=0 The table name is stored as a given size and comparison is case-sensitive
lower_case_table_names = 1 The table name is stored in lowercase on disk, but the comparison is not case-
sensitive uppercase but lowercase when comparing

5.4 Update the timestamp type field

By default, when the data row where the timestamp type field is located is updated, the field will be automatically updated to the current time, and the parameter explicit_defaults_for_timestampcontrols this behavior.

TiDB default: ON, and only supports setting this value to ON.
MySQL 5.7 default: OFF .
MySQL 8.0 default: ON .

explicit_defaults_for_timestamp=off, when the data row is updated, the timestamp type field is updated to the current time.
explicit_defaults_for_timestamp=on, when the data row is updated, the timestamp type field is not updated to the current time.

5.5 Foreign key support

TiDB default: OFF , and only supports setting this value to OFF.
MySQL 5.7 default: ON .

Guess you like

Origin blog.csdn.net/qq_21040559/article/details/127716330