MySQL Error 1170 (42000): BLOB/TEXT Column Used in Key Specification Without a Key Length MySQLÀÇ ¿À·ù 1170 (42000) : ¶§´Â / ÅØ½ºÆ® ¿¿¡ ÁÖ¿ä »ç¾ç¿¡ Ű ±æÀ̾øÀÌ »ç¿ëÇÒ
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) : ¶§´Â / ÅØ½ºÆ® ¿ÀÇ 'field_name'۸¦ »ç¾ç¿¡ Ű ±æÀ̾øÀÌ »ç¿ë
The error happens because MySQL can index only the first N chars of a BLOB or TEXT column. ¿À·ù°¡ ¹ß»ýÇϱ⠶§¹®¿¡ BLOB¸¦ ¶Ç´Â ÅØ½ºÆ® ¿À»ÀÇ »öÀÎÀ» »ý¼ºÇÒ ¼ö MySQLÀº ¸ÕÀú N¿¡¸¸ ¹®ÀÚ. 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ÀÇ Ä®·³µéÀ» ÀÔ·ÂÇϰųª ÅØ½ºÆ® ¶Ç´Â TINYBLOB, MEDIUMBLOB, LONGBLOB, TINYTEXT, MEDIUMTEXT °°Àº BLOB À¯Çü¿¡ ¼ÓÇÏ´Â 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. ¿À·ùµµ ¶§ ¾Æ´Ñ Å×À̺íÀÇ BLOB ¿¿¡ - ÅØ½ºÆ® ¹× ºñ - ÅØ½ºÆ® ¶Ç´Â À¯Çü¿¡ VARCHAR¿Í °°Àº 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. ÀÌ ¹®Á¦¸¦ ÇØ°áÇÏ·Á¸é »öÀÎ ¶Ç´Â UNIQUE Á¦¾à¿¡¼ ÅØ½ºÆ® ¶Ç´Â 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. ±âº»ÀûÀ¸·Î, ÀÚ»çÀÇ ÇѰ踦 ¾Ï½Ã a ºê¶óÄÏ VARCHAR ¿À¸¥ÂÊ À̳» ¼±¾ð, Áï VARCHAR (200) 200 ¹®ÀÚ ±æÀÌ Á¦ÇÑÀ» ÁöÁ¤ÇؾßÇÕ´Ï´Ù¿¡¸¸ 255 ÀÚ¿ÍÀÇ ÃÖ´ë·Î Á¦Çѵ˴ϴÙ.
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 MySQLÀ» °¿äÇÏ°Ô µÉ - ±×·¡¼ ¾Æ¹«°Íµµ °°Àº VARCHAR (512 ÃÖ´ë ¼ö¿ë (512) Ä®·³À» ±âº»À¸·Î »ç¿ëµÇ´Â °æ¿ì´Â ÀÌÈÄ¿¡ Ű ±æÀÌ¿¡ ¿À·ù 1170¿Í ÇÔ²² ½ÇÆÐ SMALLTEXTÀº datatype, Ű ¶Ç´Â °íÀ¯ ¾Æ´Ï¸é non - °íÀ¯ À妽º. To solve this problem, specify a figure less than 256 as the size for VARCHAR field. ÀÌ ¹®Á¦¸¦ ÇØ°áÇÏ·Á¸é, VARCHAR ÇʵåÀÇ Å©±â·Î ¼öÄ¡ 256 ¹Ì¸¸À» ÁöÁ¤ÇÒ ¼öÀÖ½À´Ï´Ù.
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¿¡¼ ¾ÆÆÄÄ¡ 2.2, MySQLÀº 5.0°ú PHP 5 - 3 ºÎ
- Change and Reset MySQL root Password MySQLÀÇ root ¾ÏÈ£¸¦ º¯°æ ¹× Àç¼³Á¤
- Create New Table by Selecting Data from Other Tables with CREATE TABLE AS Å×À̺íÀ» ¸¸µéÀ¸·Î ´Ù¸¥ Å×ÀÌºí¿¡¼ µ¥ÀÌÅ͸¦ ¼±ÅÃÇÏ¿© »õ Å×ÀÌºí ¸¸µé±â
- 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 ¿À¶óŬÀº PL / SQL ¿À¶ó - 00947 ÃæºÐÇÏÁö ¾ÊÀº °ª ¿À·ù
- Install Web Server in Windows XP with Apache2, PHP5 and MySQL4 - Part 4 À¥ ¼¹ö¸¦ ¼³Ä¡ Windows XP¿¡¼ Apache2, php5¿Í MySQL4 - Á¦ 4 ºÎ
- Enable MySQL InnoDB Storage Engine Support in XAMPP Installation MySQLÀÇ ½ºÅ丮Áö ¿£ÁøÀ» Áö¿øÇÏ´Â À̳ë Ȱ¼ºÈ XAMPP¿¡ ¼³Ä¡
- Change or Set MySQL Long Query Time Value for log-slow-queries MySQLÀº ±ä ½Ã°£À» ¼³Á¤À» º¯°æÇϰųª Äõ¸® °ª ·Î±× - ´À¸°À§ÇÑ - Äõ¸®

































August 30th, 2007 18:33 8 ¿ù 30 ÀÏ 2007 18:33
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¿¡ »ç¶÷µéÀº'Ä«Å×°í¸®¿¡ ¾ðÁ¦µçÁö ó³Ö¾ú¾î
February 20th, 2008 02:45 2 ¿ù 20 ÀÏ 2008 2½Ã 45ºÐ
Thanks! °¨»çÇÕ´Ï´Ù! Very useful post. ¸Å¿ì À¯¿ëÇÑ °Ô½ÃÇÒ ¼öÀÖ½À´Ï´Ù.
February 23rd, 2008 03:40 2008³â 2¿ù 23ÀÏ 03:40
Thanks for the post. °Ô½Ã¹°À» Áּż °¨»çÇÕ´Ï´Ù. Very helpful. ¸Å¿ì µµ¿òÀÌ.
March 7th, 2008 04:15 2008³â 3¿ù 7ÀÏ 4½Ã 15ºÐ
Thanks, very good defined °í¸¶¿ö, ¸Å¿ì Àß Á¤ÀǵÈ
October 6th, 2008 03:50 2008³â 10¿ù 6ÀÏ 03:50
Thank you very much. Áø½ÉÀ¸·Î °¨»çÇÕ´Ï´Ù. I had this problem and you were a life saver! Àú´ÂÀÌ ¹®Á¦¸¦Çß°í ´ç½ÅÀº »ý¸íÀÇ ÀºÀÎ!