[英]Unrecognize data type nvarchar in database
You do not have to worry about the nvarchar message, that was generate by phpmyadmin, not by MySQL. 您不必担心由phpmyadmin生成的nvarchar消息,而不是MySQL。 MySQL does allow nvarchar data type, see MySQL manual on national data character set : MySQL确实允许nvarchar数据类型,请参阅国家数据字符集的 MySQL手册:
Standard SQL defines NCHAR or NATIONAL CHAR as a way to indicate that a CHAR column should use some predefined character set. 标准SQL将NCHAR或NATIONAL CHAR定义为指示CHAR列应使用某些预定义字符集的方法。 MySQL uses utf8 as this predefined character set. MySQL使用utf8作为此预定义字符集。 For example, these data type declarations are equivalent: 例如,这些数据类型声明是等效的:
CHAR(10), CHARACTER SET utf8 NATIONAL CHARACTER(10), NCHAR(10) CHAR(10),CHARACTER SET utf8 NATIONAL CHARACTER(10),NCHAR(10)
As are these: 这些是:
VARCHAR(10), CHARACTER SET utf8 NATIONAL VARCHAR(10), NVARCHAR(10), NCHAR VARCHAR(10), NATIONAL CHARACTER VARYING(10), NATIONAL CHAR VARYING(10) VARCHAR(10),CHARACTER SET utf8 NATIONAL VARCHAR(10),NVARCHAR(10),NCHAR VARCHAR(10),NATIONAL CHARACTER VARYING(10),NATIONAL CHARARY VARYING(10)
The real issue is at the bottom of the error message: row size too large. 真正的问题是在错误消息的底部:行大小太大。 This error message comes from MySQL and that's the one you need to solve. 此错误消息来自MySQL,这是您需要解决的问题。
mysql uses utf8 character set for nvarchar data type. mysql对nvarchar数据类型使用utf8字符集。 An utf8 character in mysql uses up to 3 bytes. mysql中的utf8字符最多使用3个字节。 Your config_data
field is defined as nvarchar(21844)
, therefore it requires up to 21844*3+2=65534 bytes. 您的config_data
字段被定义为nvarchar(21844)
因此它最多需要21844 * 3 + 2 = 65534个字节。
As the error message says, a row can be up to 65535 bytes long, so you have 1 byte left, but the other fields push the row size above the limit. 正如错误消息所示,一行最长可达65535字节,因此您还剩1个字节,但其他字段将行大小推到限制之上。
What you can do: 你可以做什么:
config_data
field's length so the overall row length fits into the limit. 减少config_data
字段的长度,以使整个行长度符合限制。 config_data
data type to varchar and use a character set that requires less bytes - just make sure that character set supports all the characters you need. 将config_data
数据类型更改为varchar并使用需要更少字节的字符集 - 只需确保字符集支持您需要的所有字符。 config_data
data type to text
because only a small portion of a text field's value is actually stored in the row itself. 将config_data
数据类型更改为text
因为文本字段的值的一小部分实际上存储在行本身中。 This is actually suggested in the error message itself. 这实际上是在错误消息本身中建议的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.