MySQL 8.3 Release Notes
标准SQL定义NCHAR
或NATIONAL CHAR
作为指示CHAR
列使用某个预定义字符集的方式。MySQL使用utf8
作为这个预定义字符集。例如,这些数据类型声明是等效的:
CHAR(10) CHARACTER SET utf8
NATIONAL CHARACTER(10)
NCHAR(10)
如下所示:
VARCHAR(10) CHARACTER SET utf8
NATIONAL VARCHAR(10)
NVARCHAR(10)
NCHAR VARCHAR(10)
NATIONAL CHARACTER VARYING(10)
NATIONAL CHAR VARYING(10)
你可以使用N'
(或literal
'n'
)来创建一个国家字符集中的字符串。这些语句是等效的:literal
'
SELECT N'some text';
SELECT n'some text';
SELECT _utf8'some text';
MySQL 8.3 将国家字符集解释为utf8mb3
NATIONAL CHARACTER
或其同义词来定义数据库、表或列的字符集将引发类似以下的警告:
NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3, which will be
replaced by UTF8MB4 in a future release. Please consider using CHAR(x) CHARACTER
SET UTF8MB4 in order to be unambiguous.