This topic describes the compatibility between OceanBase Database's MySQL mode and native MySQL Database.
The MySQL mode of OceanBase Database is compatible with most features and statements of MySQL 5.7 and 8.0. Some features are not supported because of their limited popularity or the product architecture differences between the two databases. This topic will cover the following aspects of compatibility between OceanBase Database and MySQL Database:
Data types
SQL syntaxes
Procedural Language (PL) features
System views
Character sets
Collations
Functions and expressions
Partition support
Backup and restore
Storage engine
Optimizer
Data types
OceanBase Database supports the following data types:
Numeric data types
Integer types:
BOOL/BOOLEAN/TINYINT,SMALLINT,MEDIUMINT,INT/INTEGER, andBIGINTFixed-point types:
DECIMALandNUMERICFloating-point types:
FLOATandDOUBLEBit-value type:
BIT
Date and time types:
DATETIME,TIMESTAMP,DATE,TIME, andYEARCharacter types:
CHAR,VARCHAR,BINARY, andVARBINARYLarge object types:
TINYBLOB,BLOB,MEDIUMBLOB, andLONGBLOBText types:
TINYTEXT,TEXT,MEDIUMTEXT,LONGTEXT, andSTRINGNote
For OceanBase Database V4.3.5, the text data type
STRINGis supported starting from V4.3.5 BP1.Enumeration type:
ENUMSet type:
SETJSON data types
Spatial data types
Roaring Bitmap data types
Array data types
Vector data types
SQL syntaxes
SELECT
Supports most query features, including single- and multi-table queries, subqueries, inner joins, semi joins, outer joins, grouping, aggregation, and regular data mining functions such as probability and linear regression functions.
Allows you to perform set operations such as
UNION,UNION ALL,MINUS,EXCEPT, andINTERSECTon the results of multipleSELECTqueries.Supports the
EXPLAINstatement for viewing execution plans.
INSERT
Supports single- and multi-row inserts. OceanBase Database also supports inserting data into a specified partition.
Supports the
INSERT INTO ... SELECT ...statement.
UPDATE
Supports single- and multi-column updates.
Supports updates by using subqueries.
Supports set updates.
DELETE
- Supports single- and multi-table deletion.
TRUNCATE
- Allows you to truncate a specified table.
SELECT
- Does not support the
SELECT ... FOR SHARE ...statement.
TRUNCATE
- Does not support truncating a table that has a transaction in progress or a table that is being locked.
PL features
OceanBase Database is compatible with most PL features of MySQL Database, including:
- Data types
- Stored procedures
- Custom functions
- Triggers
- Exception handling
OceanBase Database also supports specific MySQL PL packages, such as DBMS_RESOURCE_MANAGER, DBMS_STATS, DBMS_UDR, DBMS_XPLAN, and DBMS_WORKLOAD_REPOSITORY.
For more information about PL features, see PL reference.
System views
OceanBase Database implements most views in the information_schema and mysql databases of MySQL Database. However, due to architectural differences, OceanBase Database does not implement all views in MySQL Database or ensure consistency with MySQL Database in all column meanings of the views.
For more information about system views, see Overview of system views.
Character sets
OceanBase Database supports the following character sets:
binary
utf8mb4/utf8mb3
Note
utf8mb3is an alias ofutf8mb4.gbk
utf16
utf16le
gb18030
latin1
gb18030_2022
ascii
tis620
sjis
big5
dec8
gb2312
ujis
euckr
eucjpms
cp932
cp850
hp8
macroman
swe7
Note
For OceanBase Database V4.3.5, the following character sets are supported starting from V4.3.5 BP1: gb2312, ujis, euckr, eucjpms, cp932, cp850, hp8, macroman, and swe7.
Collations
The following collations are supported in OceanBase Database.
| Collation | Character set | Description |
|---|---|---|
| utf8mb4_general_ci | utf8mb4 | Uses general collation. |
| utf8mb4_bin | utf8mb4 | Uses binary collation. |
| utf8mb4_unicode_ci | utf8mb4 | Uses collation based on the Unicode Collation Algorithm (UCA). |
| utf8mb4_unicode_520_ci | utf8mb4 | Uses the collation rules of Unicode V5.2.0. It follows Unicode code point sorting and ignores case differences. |
| utf8mb4_croatian_ci | utf8mb4 | Uses Croatian collation rules. utf8mb4_croatian_ci is compatible with utf8_croatian_ci. |
| utf8mb4_czech_ci | utf8mb4 | Uses Czech collation rules. |
| utf8mb4_0900_ai_ci | utf8mb4 | Uses Unicode version 9.0.0 collation rules and order, ignoring case differences and treating uppercase and lowercase letters as the same character. |
| binary | binary | Uses binary collation. |
| gbk_chinese_ci | gbk | Uses Chinese language collation. |
| gbk_bin | gbk | Uses binary collation. |
| utf16_general_ci | utf16 | Uses general collation. |
| utf16_bin | utf16 | Uses binary collation. |
| utf16_unicode_ci | utf16 | Uses collation based on the UCA. |
| utf8mb4_german2_ci | utf16le | Uses German collation rules. |
| utf8mb4_croatian_ci | utf16le | Uses Croatian collation rules. |
| gb18030_chinese_ci | gb18030 | Uses Chinese language collation. |
| gb18030_bin | gb18030 | Uses binary collation. |
| latin1_swedish_ci | latin1 | Uses Swedish/Finnish collation. |
| latin1_german1_ci | latin1 | Uses collation for the German language environment in the latin1 character set. |
| latin1_danish_ci | latin1 | Uses collation for the Danish language environment in the latin1 character set. |
| latin1_german2_ci | latin1 | Used for German environments, suitable for applications needing dictionary order character comparison. |
| latin1_general_ci | latin1 | Used for case-insensitive scenarios supporting diacritics, such as database designs for some European languages. |
| latin1_general_cs | latin1 | Used for case-sensitive general collation, supporting multiple languages (for example, Western European languages). |
| latin1_spanish_ci | latin1 | Used for collation in the Spanish language environment. |
| latin1_bin | latin1 | Uses binary collation for latin1. |
| gb18030_2022_bin | gb18030_2022 | Uses binary collation. |
| gb18030_2022_chinese_ci | gb18030_2022 | Uses pinyin collation, which is case-insensitive. |
| gb18030_2022_chinese_cs | gb18030_2022 | Uses pinyin collation, which is case-sensitive. |
| gb18030_2022_radical_ci | gb18030_2022 | Uses radical-stroke collation, which is case-insensitive. |
| gb18030_2022_radical_cs | gb18030_2022 | Uses radical-stroke collation, which is case-sensitive. |
| gb18030_2022_stroke_ci | gb18030_2022 | Uses stroke collation, which is case-insensitive. |
| gb18030_2022_stroke_cs | gb18030_2022 | Uses stroke collation, which is case-sensitive. |
| ascii_bin | ascii | Uses binary collation. |
| ascii_general_ci | ascii | Uses case-insensitive alphabetical collation, treating uppercase and lowercase letters as the same. |
| tis620_bin | tis620 | Uses binary collation. |
| tis620_thai_ci | tis620 | Uses Thai collation, which is case-insensitive. |
| sjis_japanese_ci | sjis | Uses Japanese collation rules. |
| dec8_swedish_ci | dec8 | Uses Swedish collation rules. |
| gb2312_chinese_ci | gb2312 | Uses GB2312 character set, performs case-insensitive sorting according to Chinese collation.
NoteFor OceanBase Database V4.3.5, this collation is supported since V4.3.5 BP1. |
| gb2312_bin | gb2312 | Uses GB2312 character set, performs case-sensitive sorting in binary order.
NoteFor OceanBase Database V4.3.5, this collation is supported since V4.3.5 BP1. |
| ujis_japanese_ci | ujis | Uses UJIS character set, performs case-insensitive sorting according to Japanese collation.
NoteFor OceanBase Database V4.3.5, this collation is supported since V4.3.5 BP1. |
| ujis_bin | ujis | Uses UJIS character set, performs case-sensitive sorting in binary order.
NoteFor OceanBase Database V4.3.5, this collation is supported since V4.3.5 BP1. |
| euckr_korean_ci | euckr | Uses EUCKR character set, performs case-insensitive sorting according to Korean collation.
NoteFor OceanBase Database V4.3.5, this collation is supported since V4.3.5 BP1. |
| euckr_bin | euckr | Uses EUCKR character set, performs case-sensitive sorting in binary order.
NoteFor OceanBase Database V4.3.5, this collation is supported since V4.3.5 BP1. |
| eucjpms_japanese_ci | eucjpms | Uses EUCJPMS character set, performs case-insensitive sorting according to Japanese collation.
NoteFor OceanBase Database V4.3.5, this collation is supported since V4.3.5 BP1. |
| eucjpms_bin | eucjpms | Uses EUCJPMS character set, performs case-sensitive sorting in binary order.
NoteFor OceanBase Database V4.3.5, this collation is supported since V4.3.5 BP1. |
| cp932_japanese_ci | cp932 | Uses CP932 character set, performs case-insensitive sorting according to Japanese collation.
NoteFor OceanBase Database V4.3.5, this collation is supported since V4.3.5 BP1. |
| cp932_bin | cp932 | Uses CP932 character set, performs case-sensitive sorting in binary order.
NoteFor OceanBase Database V4.3.5, this collation is supported since V4.3.5 BP1. |
| cp850_general_ci | cp850 | Uses CP850 character set, performs case-insensitive sorting according to general collation.
NoteFor OceanBase Database V4.3.5, this collation is supported since V4.3.5 BP1. |
| cp850_bin | cp850 | Uses CP850 character set, performs case-sensitive sorting in binary order.
NoteFor OceanBase Database V4.3.5, this collation is supported since V4.3.5 BP1. |
| hp8_english_ci | hp8 | Uses HP8 character set, performs case-insensitive sorting according to English collation.
NoteFor OceanBase Database V4.3.5, this collation is supported since V4.3.5 BP1. |
| hp8_bin | hp8 | Uses HP8 character set, performs case-sensitive sorting in binary order.
NoteFor OceanBase Database V4.3.5, this collation is supported since V4.3.5 BP1. |
| macroman_general_ci | macroman | Uses MacRoman character set, performs case-insensitive sorting according to general collation.
NoteFor OceanBase Database V4.3.5, this collation is supported since V4.3.5 BP1. |
| macroman_bin | macroman | Uses MacRoman character set, performs case-sensitive sorting in binary order.
NoteFor OceanBase Database V4.3.5, this collation is supported since V4.3.5 BP1. |
| swe7_swedish_ci | swe7 | Uses SWE7 character set, performs case-insensitive sorting according to Swedish collation.
NoteFor OceanBase Database V4.3.5, this collation is supported since V4.3.5 BP1. |
| swe7_bin | swe7 | Uses SWE7 character set, performs case-sensitive sorting in binary order.
NoteFor OceanBase Database V4.3.5, this collation is supported since V4.3.5 BP1. |
Functions
The analytic (window) functions supported by OceanBase Database are a superset of those supported by MySQL Database. This means that OceanBase Database supports all analytic (window) functions supported by MySQL Database.
The MySQL mode of OceanBase Database does not support the following functions:
String functions:
LOAD_FILE()andMATCH()XML functions:
ExtractValue()andUpdateXML()Other functions:
MASTER_POS_WAIT()
Partition support
The partition support feature of OceanBase Database differs from that of MySQL Database in the following aspects:
OceanBase Database supports partitioning, template-based subpartitioning, and non-template-based subpartitioning. MySQL Database does not support non-template-based subpartitioning.
OceanBase Database supports HASH, KEY, RANGE, RANGE COLUMNS, LIST, and LIST COLUMNS subpartitioning. MySQL Database supports only HASH and KEY subpartitioning.
OceanBase Database supports adding and dropping subpartitions in partitioned tables. MySQL Database does not support adding and dropping subpartitions.
Notice
- Adding and dropping subpartitions is not supported for scenarios where the subpartition type is HASH or KEY.
- In OceanBase Database V4.3.5, support for adding subpartitions is available starting from V4.3.5 BP1.
For more information about partitions, see Partition overview.
Backup and restore
OceanBase Database is compatible with some backup and restore features of MySQL Database.
Full backup and incremental backup
Hot backup
Table-level and database-level restore
Restore to a specified path
Cluster-level backup and restore
Cold backup
Subpartition-level backup
Verification of backup data
Storage engine
Unlike the InnoDB and MyISAM storage engines in MySQL Database, the storage engine in OceanBase Database is based on the LSM-tree architecture.
Optimizer
OceanBase Database is compatible with some optimizer features of MySQL Database. For more information about the optimizer, see SQL tuning.
Commands to view execution plans:
- The output columns of the execution plan view include only
ID,OPERATOR,NAME,EST. ROWS, andCOST, as well as the details of operators.
- The output columns of the execution plan view include only
Statistics queries:
You can manually query the histogram statistics information stored in the data dictionary table by executing the
ANALYZE TABLEstatement.You can automatically view table statistics and column statistics through views.
Query rewriting and optimization:
Outer join optimization
Outer join simplification
Block Nested-Loop (BNL) and Batched Key Access (BKA) joins
Conditional filtering
Constant folding optimization
IS NULLoptimization (indexes do not storeNULLvalues)ORDER BYoptimizationGROUP BYoptimizationElimination by using
DISTINCTLIMITpushdownWindow function optimization
Avoiding full table scan
Predicate pushdown
Optimizer hint mechanism:
Join-order optimizer hints
Table-level optimizer hints
Index-level optimizer hints
INDEX,FULL,ORDERED, andLEADINGhints
Parallel execution capabilities such as parallel query, parallel replication, and parallel write, which are compatible with those in MySQL Database. OceanBase Database also supports parallel operations such as parallel aggregation, parallel join, parallel grouping, and parallel sorting.
Plan caching and precompilation, which are not supported by MySQL Database.
Commands to view execution plans:
- Does not support the
SHOW WARNINGSstatement for displaying additional information about execution plans.
- Does not support the