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:新しいテーブルを作成するとき、または既存のテーブルに主キーを変更する、独自の制約とインデックスか、または新しいインデックスを定義するときにALTER TABLEの声明にMySQLのデータベースの操作は、次のエラーが発生することが禁止すると、コマンドを完了:
ERROR 1170 (42000): BLOB/TEXT column ‘field_name’ used in key specification without a key lengthエラーが発生1170 ( 42000 ) :のBLOB / TEXTカラム' 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やテキストの種類としては、 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.のエラーが発生する場合もポップアップしようとしたときにテーブルからカラムを1列に変換するに非テキストと非BLOB型のようなテキストまたはvarcharおよび列挙型をBLOB型で、その列として定義されて既に独自の制約またはインデックスです。 The Alter Table SQL command will fail.テーブルには、 ALTER 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年5月にも、エラーが表示されます。 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 私のデジタルライフフォーラム .です。
Related Articles関連記事
- How to Convert Character Set and Collation of WordPress Databaseどのように変換するデータベースのキャラクタセットおよび照合順序のWordPress
- Installing Web Server in FreeBSD 6.0 with Apache 2.2, MySQL 5.0 and PHP 5 - Part 3 FreeBSDの6.0をインストールするWebサーバーのApache 2.2 、 MySQL 5.0以降およびPHP 5 -パート3
- Create New Table by Selecting Data from Other Tables with CREATE TABLE AS新しいテーブルの作成を選択し、他のテーブルからデータテーブルを作成する
- Install Web Server in Windows XP with Apache2, PHP5 and MySQL4 - Part 4ウェブサーバーでは、 Windows XPをインストールするのApache2 、 PHP5とmysql4 -パート4
- Change and Reset MySQL root Password MySQLのrootのパスワードを変更し、リセット
- ORA-02449 Oracle Drop Table Errorエラーが発生OracleのドロップテーブルのOra - 02449
- Enable MySQL InnoDB Storage Engine Support in XAMPP Installation MySQLのInnoDBストレージエンジンのサポートを有効にXAMPPインストール
- WordPress MySQL SQL Query Error in WPDB Class WordPressのMySQLのSQLクエリにエラーが発生wpdbクラス
- Easily Duplicate, Copy or Backup Tables in Oracle, PostgreSQL, DB2 and SQLite with Create Table As SQL簡単に重複し、オラクルのテーブルのバックアップコピーまたは、 PostgreSQLでテーブルを作成するとしてのDB2とSQLiteのSQL
- Oracle PL/SQL ORA-00947 Not Enough Values Error OracleのPL / SQLのに十分な値エラーが発生しないのOra - 00947

































August 30th, 2007 18:33 2007年8月30日18:33
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私ならば、 ' 6758人々 'カテゴリいつでも
February 20th, 2008 02:45 2008年2月20日02:45
Thanks!ありがとう! Very useful post.非常に有益なポストを作成。
February 23rd, 2008 03:40 2008年2月23日03:40
Thanks for the post.ポストてくれてありがとう。 Very helpful.非常にhelpful 。
March 7th, 2008 04:15 2008年3月7日04:15
Thanks, very good definedありがとう、非常に良い定義されて