MySQL Error 1170 (42000): BLOB/TEXT Column Used in Key Specification Without a Key Length MySQL的错误1170 ( 42000 ) : BLOB的/文本列中使用的主要规格,没有一个密钥长度

When creating a new table or altering an existing table with primary keys, unique constraints and indexes, or when defining a new index with Alter Table manipulation statement in MySQL database, the following error may occur and prohibit the the command from completing:当创建一个新表或改变现有的资料表与主键,独特的制约因素和指标,或当确定一个新的指数与改变表操纵的声明在MySQL数据库,下面的错误,可能会出现和禁止命令完成:

ERROR 1170 (42000): BLOB/TEXT column ‘field_name’ used in key specification without a key length错误1170 ( 42000 ) : BLOB的/纯文字栏' field_name '用在关键的规格没有一个密钥长度

The error happens because MySQL can index only the first N chars of a BLOB or TEXT column.错误发生,因为MySQL的,可以编制索引,只有前n字一个的BLOB或文本列。 So The error mainly happen when there is a field/column type of TEXT or BLOB or those belongs to TEXT or BLOB types such as TINYBLOB, MEDIUMBLOB, LONGBLOB, TINYTEXT, MEDIUMTEXT, and LONGTEXT that you try to make as primary key or index.因此错误主要发生时,有一个外地/列类型的文字或BLOB的或那些属于文字或BLOB的类型,如tinyblob , mediumblob , longblob , tinytext , mediumtext , longtext您尝试,使作为主键或索引。 With full BLOB or TEXT without the length value, MySQL is unable to guarantee the uniqueness of the column as it’s of variable and dynamic size.与充分的BLOB或文字没有长度值, MySQL的,是无法保证的唯一一栏,因为它的可变和动态的大小。 So, when using BLOB or TEXT types as index, the value of N must be supplied so that MySQL can determine the key length.所以,当使用的BLOB或TEXT类型作为指数,价值的N必须提供使MySQL的可确定密钥长度。 However, MySQL doesn’t support limit on TEXT or BLOB.然而, MySQL的不支持限制的文字或BLOB的。 TEXT(88) simply won’t work.文字( 88 )是行不通的。

The error will also pop up when you try to convert a table column from non-TEXT and non-BLOB type such as VARCHAR and ENUM into TEXT or BLOB type, with the column already been defined as unique constraints or index.错误也将弹出当您尝试转换表列从非文字和非BLOB的类型,如varchar和的ENUM到文本或BLOB的类型,与列已经被定义为独特的限制,或指数。 The Alter Table SQL command will fail.该改变表SQL命令就会失败。

The solution to the problem is to remove the TEXT or BLOB column from the index or unique constraint, or set another field as primary key.问题的解决方法是删除文字或BLOB的列从索引或唯一约束,或设置的另一个领域作为主键。 If you can’t do that, and wanting to place a limit on the TEXT or BLOB column, try to use VARCHAR type and place a limit of length on it.如果你不能做到这一点,并要设立一个限制,对文本的BLOB或专栏,尝试使用varchar类型和地点的限制长度对。 By default, VARCHAR is limited to a maximum of 255 characters and its limit must be specified implicitly within a bracket right after its declaration, ie VARCHAR(200) will limit it to 200 characters long only.默认情况下, varchar是限于最多255个字符及其限度必须指定含蓄地在一个支架后,其权利宣言,即varchar ( 200 )会限制它有200个字元,长期只。

Sometimes, even though you don’t use TEXT or BLOB related type in your table, the Error 1170 may also appear.有时,即使您不使用文字或BLOB的相关输入您的表,误差1170年,也可能出现。 It happens in situation such as when you specify VARCHAR column as primary key, but wrongly set its length or characters size.它发生的情况,例如当您指定varchar列作为主键,但错误设置它的长度或字符的大小。 VARCHAR can only accepts up to 256 characters, so anything such as VARCHAR(512) will force MySQL to auto-convert the VARCHAR(512) to a SMALLTEXT datatype, which subsequently fail with error 1170 on key length if the column is used as primary key or unique or non-unique index. varchar只能接受多达256个字符,因此任何如varchar ( 512 ) ,将迫使MySQL的自动转换为varchar ( 512 )一smalltext数据,随后失败与错误, 1170年对密钥长度,如果栏是用来作为小学关键或独特性或非唯一索引。 To solve this problem, specify a figure less than 256 as the size for VARCHAR field.要解决这个问题,指定一个数字少于256作为大小为varchar领域。

IMPORTANT : This is a machine translated page which is provided "as is" without warranty. 重要说明 :这是一个机器翻译网页是“按原样”提供的担保。 Machine translation may be difficult to understand.机器翻译可能很难理解。 Please refer to请参阅 original English article英文原版的文章 whenever possible.只要有可能。

Share and contribute or get technical support and help at分享和贡献,或取得技术的支持和帮助,在 My Digital Life Forums 我的数字生活论坛 .



4 Responses to “MySQL Error 1170 (42000): BLOB/TEXT Column Used in Key Specification Without a Key Length” 4回应“ MySQL的错误1170 ( 42000 ) : BLOB的/文本列中使用的主要规格,没有一个密钥长度”

  1. Felix费利克斯
    August 30th, 2007 18:33 2007年8月30日18时33分
    1

    Thanks for putting this up.感谢这个了。 I didn’t get the error and you saved me a lot o frustration.我没有错误,你救了我很多o挫折感。 I’d put you in the ‘Goog people’ category anytime我要你在' goog人'类别随时 ;-)

  2. Ben Hardy本哈
    February 20th, 2008 02:45 2008年2月20日2时45分
    2

    Thanks!谢谢! Very useful post.非常有用的职位。

  3. Jamie Slater杰米史莱特
    February 23rd, 2008 03:40 2008年2月23日3时40分
    3

    Thanks for the post.感谢该职位。 Very helpful.非常有帮助。

  4. Reza雷札
    March 7th, 2008 04:15 2008年3月7日4时15分
    4

    Thanks, very good defined感谢,很好的界定

Leave a Reply离开的答复

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> 您可以使用这些标签:的<a href="" title=""> <abbr title=""> <acronym title="">的<b> <blockquote cite=""> <cite>的<code> <删除日期时间= “ ” >的<em>的<i> <q cite=""> <strike>的<strong>

Subscribe without commenting订阅无评论


Custom Search

New Articles新的条款,

Incoming Search Terms for the Article传入的搜索条件文章

BLOB/TEXT column used in key specification without a key length 的BLOB /文本列中使用的主要规格,没有一个密钥长度 - - used in key specification without a key length 用在关键的规格没有一个密钥长度 - - mysql error 1170 MySQL的错误1170 - - BLOB/TEXT column used in key specification without a key length 的BLOB /文本列中使用的主要规格,没有一个密钥长度 - - used in key specification without a key length 用在关键的规格没有一个密钥长度 - - BLOB/TEXT column used in key specification without a key length 的BLOB /文本列中使用的主要规格,没有一个密钥长度 - - BLOB/TEXT column 'name' used in key specification without a key length BLOB的/纯文字栏 ' 名称'用在关键的规格没有一个密钥长度 - - mysql used in key specification without a key length MySQL的使用在关键的规格没有一个密钥长度 - - #1170 - BLOB/TEXT column used in key specification without a key length # 1170年-的B LOB/文本列中使用的主要规格,没有一个密钥长度 - - ERROR 1170 (42000) at line 77: BLOB/TEXT column 'jid' used in key specification without a key length 错误1170 ( 42000 )行77 : BLOB的/纯文字栏' jid ' 用在关键的规格没有一个密钥长度 - - #1170 - BLOB/TEXT column 'name' used in key specification without a key length # 1170年-的B LOB/文本列'名称'用在关键的规格没有一个密钥长度 - - mysql 1170 MySQL的1170 - - mysql #1170 MySQL的1170 # - - #1170 - BLOB/TEXT column used in key specification without a key length # 1170年-的B LOB/文本列中使用的主要规格,没有一个密钥长度 - - error 1170 mysql 1170年MySQL的错误 - - mysql text key MySQL的文本的关键 - - "used in key specification without a key length" “用在关键的规格没有一个密钥长度” - - mysql error number 1170 MySQL的错误编号1170 - - error 1170 1170错误 - - used in key specification without key length 所使用的关键规格,密钥长度 - - #1170 - BLOB/TEXT column used in key specification without a key length # 1170年-的B LOB/文本列中使用的主要规格,没有一个密钥长度 - - mysql "used in key specification without a key length" MySQL的“用在关键的规格没有一个密钥长度” - - key specification without a key length 关键的规格没有一个密钥长度 - - ERROR 1170 (42000) 错误117042000 ) - - The used table type doesn't support BLOB/TEXT columns 用过的表类型不支持的BLOB /文本栏目 - - #1170 - BLOB/TEXT column used in key specification without a key length # 1170年-的B LOB/文本列中使用的主要规格,没有一个密钥长度 - - BLOB/TEXT column used in key specification without a key length 的BLOB /文本列中使用的主要规格,没有一个密钥长度 - - The used table type doesn't support BLOB/TEXT columns 用过的表类型不支持的BLOB /文本栏目 - - ERROR 1170 (42000): BLOB/TEXT column used in key specification without a key length 错误1170 ( 42000 ) : BLOB的/文本列中使用的主要规格,没有一个密钥长度 - - column used in key specification without a key length 专栏中使用的主要规格,没有一个密钥长度 - - mysql text unique MySQL的文字独特 - - ERROR 1170 (42000): BLOB/TEXT column used in key specification without a key length 错误1170 ( 42000 ) : BLOB的/文本列中使用的主要规格,没有一个密钥长度 - - BLOB/TEXT column 'Name' used in key specification without a key length BLOB的/纯文字栏 ' 名称'用在关键的规格没有一个密钥长度 - - BLOB/TEXT column 'id' used in key specification without a key length BLOB的/纯文字栏 ' 身份证'用在关键的规格没有一个密钥长度 - - MySQL KEY TEXT MySQL中的关键文字 - - BLOB/TEXT column 'value' used in key specification without a key length BLOB的/纯文字栏 ' 价值'用在关键的规格没有一个密钥长度 - - used in key specification without a key length mysql 用在关键的规格没有一个密钥长度的MySQL - - #1170 - BLOB/TEXT # 1170年-的B LOB/文 - - #1170 - BLOB/TEXT column 'name' used in key specification without a key length # 1170年-的B LOB/文本列'名称'用在关键的规格没有一个密钥长度 - - BLOB/TEXT column 'jid' used in key specification without a key length BLOB的/纯文字栏 ' jid '用在关键的规格没有一个密钥长度 - - #1170 - BLOB/TEXT column # 1170年-的B LOB/文本列 - - mysql ERROR 1170 (42000) MySQL的错误1170 ( 42000 ) - - mysql BLOB/TEXT column used in key specification without a key length MySQL中的BLOB /文本列中使用的主要规格,没有一个密钥长度 - - #1170 - BLOB/TEXT column 'Title' used in key specification without a key length # 1170年-的B LOB/文本列'标题'用在关键的规格没有一个密钥长度 - - BLOB/TEXT column '' used in key specification without a key length 的BLOB /文本列''用在关键的规格没有一个密钥长度 - - "key specification without a key length" “关键的规格没有密钥长度” - - mysql text key length MySQL的文本密钥长度 - - #1170 - BLOB/TEXT column 'id' used in key specification without a key length # 1170年-的B LOB/文本列为' i d'用在关键的规格没有一个密钥长度 - - mysql blob key MySQL的BLOB的关键 - - without a key length 没有一个密钥长度 - -