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 /文本列中使用的主要規格,沒有一個密鑰長度 - - mysql used in key specification without a key length MySQL的使用在關鍵的規格沒有一個密鑰長度 - - BLOB/TEXT column 'name' used in key specification without a key length BLOB的/純文字欄 ' 名稱'用在關鍵的規格沒有一個密鑰長度 - - 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 used in key specification without a key length # 1170年-的B LOB/文本列中使用的主要規格,沒有一個密鑰長度 - - "used in key specification without a key length" “用在關鍵的規格沒有一個密鑰長度” - - #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 error number 1170 MySQL的錯誤編號1170 - - mysql text key MySQL的文本的關鍵 - - mysql "used in key specification without a key length" MySQL的“用在關鍵的規格沒有一個密鑰長度” - - error 1170 1170錯誤 - - ERROR 1170 (42000) 錯誤117042000 ) - - used in key specification without key length 所使用的關鍵規格,密鑰長度 - - #1170 - BLOB/TEXT column used in key specification without a key length # 1170年-的B LOB/文本列中使用的主要規格,沒有一個密鑰長度 - - key specification without a key length 關鍵的規格沒有一個密鑰長度 - - 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 'Name' used in key specification without a key length BLOB的/純文字欄 ' 名稱'用在關鍵的規格沒有一個密鑰長度 - - The used table type doesn't support BLOB/TEXT columns 用過的表類型不支持的BLOB /文本欄目 - - mysql text unique MySQL的文字獨特 - - BLOB/TEXT column used in key specification without a key length 的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 專欄中使用的主要規格,沒有一個密鑰長度 - - ERROR 1170 (42000): BLOB/TEXT column used in key specification without a key length 錯誤1170 ( 42000 ) : 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的/純文字欄 ' 價值'用在關鍵的規格沒有一個密鑰長度 - - mysql BLOB/TEXT column used in key specification without a key length MySQL中的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 ) - - #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 沒有一個密鑰長度 - -