无法识别数据库中的数据类型 nvarchar [英] Unrecognize data type nvarchar in database

查看:69
本文介绍了无法识别数据库中的数据类型 nvarchar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试将 MySQL 服务器数据导入 PHPMyAdmin MySQL 数据库.发现无法识别的数据类型nvarchar".我的数据库排序规则设置为utf_general_ci".

I tried to import MySQL Server data into PHPMyAdmin MySQL database. Unrecognized data type "nvarchar" found. My database collation set to "utf_general_ci".

推荐答案

您不必担心 nvarchar 消息,它是由 phpmyadmin 生成的,而不是由 MySQL 生成的.MySQL 确实允许 nvarchar 数据类型,请参阅 MySQL 手册关于 国家数据字符设置:

You do not have to worry about the nvarchar message, that was generate by phpmyadmin, not by MySQL. MySQL does allow nvarchar data type, see MySQL manual on national data character set:

标准 SQL 将 NCHAR 或 NATIONAL CHAR 定义为指示CHAR 列应该使用一些预定义的字符集.MySQL 使用utf8 作为这个预定义的字符集.例如,这些数据类型声明是等价的:

Standard SQL defines NCHAR or NATIONAL CHAR as a way to indicate that a CHAR column should use some predefined character set. MySQL uses utf8 as this predefined character set. For example, these data type declarations are equivalent:

CHAR(10), CHARACTER SET utf8 国家字符(10), NCHAR(10)

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变化(10)

VARCHAR(10), CHARACTER SET utf8 NATIONAL VARCHAR(10), NVARCHAR(10), NCHAR VARCHAR(10), NATIONAL CHARACTER VARYING(10), NATIONAL CHAR VARYING(10)

真正的问题是在错误消息的底部:行大小太大.此错误消息来自 MySQL,这是您需要解决的问题.

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 对 nvarchar 数据类型使用 utf8 字符集.mysql 中的 utf8 字符最多使用 3 个字节.您的 config_data 字段定义为 nvarchar(21844),因此它最多需要 21844*3+2=65534 字节.

mysql uses utf8 character set for nvarchar data type. An utf8 character in mysql uses up to 3 bytes. Your config_data field is defined as nvarchar(21844), therefore it requires up to 21844*3+2=65534 bytes.

正如错误消息所说,一行最多可以有 65535 个字节长,因此您还剩下 1 个字节,但其他字段将行大小推到了限制之上.

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.

你可以做什么:

  1. 减少 config_data 字段的长度,使整个行长度符合限制.
  2. config_data 数据类型更改为 varchar 并使用需要较少字节的字符集 - 只需确保该字符集支持您需要的所有字符即可.
  3. config_data 数据类型更改为text,因为实际上只有一小部分文本字段值存储在行本身中.这实际上是在错误消息本身中建议的.
  1. Reduce config_data field's length so the overall row length fits into the limit.
  2. Change 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.
  3. Change config_data data type to text because only a small portion of a text field's value is actually stored in the row itself. This is actually suggested in the error message itself.

这篇关于无法识别数据库中的数据类型 nvarchar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆