MySQL錯誤1170年(42000) : 用於關鍵規格的BLOB/TEXT專欄,不用一個關鍵字長度

當創造一張新的桌或修改一張現有的桌以主關鍵字時,獨特的限制和索引,或者,當定義時一個新的索引與在MySQL數據庫修改表操作聲明,以下錯誤也許生成和禁止命令完成:

錯誤1170年(42000) : BLOB/TEXT專欄`field_name』在關鍵規格使用了,不用一個關鍵字長度

因為MySQL可能標註BLOB或文本專欄的仅第一N炭灰,錯誤發生。 如此錯誤主要發生,當有領域或文本的專欄類型或BLOB或者那些屬於文本或BLOB類型例如TINYBLOB、MEDIUMBLOB、LONGBLOB、TINYTEXT、您設法做作為主關鍵字或索引的MEDIUMTEXT和LONGTEXT。 與充分的沒有長度價值的BLOB或文本,因為它是易變和動態大小, MySQL無法保證專欄的獨特。 如此,當使用BLOB或文本類型作為索引時,必須提供N的價值,以便MySQL可能確定關鍵字長度。 然而, MySQL在文本或BLOB不支持極限。 文本(88)不會簡單地運作。

當您設法轉換一個桌專欄從非文本和非BLOB類型例如VARCHAR和ENUM成文本或BLOB類型,與專欄已經被定義成獨特的限制或索引,錯誤也將突然出現。 修改表SQL命令將發生故障。

對問題的解答將從索引或獨特的限制去除文本或BLOB專欄,或者設置另一個領域作為主關鍵字。 如果您在文本或BLOB專欄,嘗試不可能做那和想要安置極限使用VARCHAR類型和安置長度極限對此。 默認情況下, VARCHAR被限制到最多255個字符,并且必須在一個托架之內含蓄地指定它的極限在它的聲明之後,即VARCHAR (200)長期將限制它到200個字符只。

有時,即使您在您的桌裡不使用文本或BLOB相關的類型,錯誤1170也許也出現。 它在情況發生例如,當您指定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. To solve this problem, specify a figure less than 256 as the size for VARCHAR field.

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”

  1. Felix
    August 30th, 2007 18:33
    1

    Thanks for putting this up. I didn’t get the error and you saved me a lot o frustration. I’d put you in the ‘Goog people’ category anytime ;-)

  2. Ben Hardy
    February 20th, 2008 02:45
    2

    Thanks! Very useful post.

  3. Jamie Slater
    February 23rd, 2008 03:40
    3

    Thanks for the post. Very helpful.

  4. Reza
    March 7th, 2008 04: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>

Subscribe without commenting


Custom Search

New Articles

Incoming Search Terms for the Article

BLOB/TEXT column used in key specification without a key length - used in key specification without a key length - mysql error 1170 - BLOB/TEXT column used in key specification without a key length - used in key specification without a key length - BLOB/TEXT column used in key specification without a key length - mysql used in key specification without a key length - BLOB/TEXT column 'name' used in key specification without a key length - ERROR 1170 (42000) at line 77: BLOB/TEXT column 'jid' used in key specification without a key length - #1170 - BLOB/TEXT column used in key specification without a key length - "used in key specification without a key length" - #1170 - BLOB/TEXT column 'name' used in key specification without a key length - mysql 1170 - mysql #1170 - #1170 - BLOB/TEXT column used in key specification without a key length - error 1170 mysql - mysql error number 1170 - mysql text key - mysql "used in key specification without a key length" - error 1170 - ERROR 1170 (42000) - used in key specification without key length - #1170 - BLOB/TEXT column used in key specification without a key length - key specification without a key length - The used table type doesn't support BLOB/TEXT columns - #1170 - BLOB/TEXT column used in key specification without a key length - BLOB/TEXT column 'Name' used in key specification without a key length - The used table type doesn't support BLOB/TEXT columns - BLOB/TEXT column used in key specification without a key length - ERROR 1170 (42000): BLOB/TEXT column used in key specification without a key length - column used in key specification without a key length - mysql text unique - ERROR 1170 (42000): BLOB/TEXT column used in key specification without a key length - BLOB/TEXT column 'id' used in key specification without a key length - MySQL KEY TEXT - BLOB/TEXT column 'value' used in key specification without a key length - mysql BLOB/TEXT column used in key specification without a key length - used in key specification without a key length mysql - #1170 - BLOB/TEXT - #1170 - BLOB/TEXT column 'name' used in key specification without a key length - BLOB/TEXT column 'jid' used in key specification without a key length - #1170 - BLOB/TEXT column - mysql ERROR 1170 (42000) - #1170 - BLOB/TEXT column 'Title' used in key specification without a key length - BLOB/TEXT column '' used in key specification without a key length - "key specification without a key length" - mysql text key length - #1170 - BLOB/TEXT column 'id' used in key specification without a key length - mysql blob key - without a key length -