MySQL Error 1170 (42000): BLOB/TEXT Column Used in Key Specification Without a Key Length MySQL Error 1170 (42000): BLOB / columna de texto usados en Key Especificación Sin una Longitud de la clave
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: Al crear una nueva tabla o modificar una tabla existente con claves primarias, únicas limitaciones e índices, o la hora de definir un nuevo índice con ALTER TABLE declaración en la manipulación de bases de datos MySQL, el siguiente mensaje de error puede ocurrir y prohibir el comando de la realización:
ERROR 1170 (42000): BLOB/TEXT column ‘field_name’ used in key specification without a key length ERROR 1170 (42000): BLOB / TEXTO columna 'field_name »utilizado en clave sin una especificación de la duración de
The error happens because MySQL can index only the first N chars of a BLOB or TEXT column. El error ocurre porque MySQL puede indexar sólo los primeros n caracteres de un BLOB o TEXT columna. 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. Así que el error ocurra, principalmente cuando hay un campo / columna tipo de texto o BLOB o pertenece a los TEXTO o tipos BLOB como TINYBLOB, MEDIUMBLOB, LONGBLOB, TINYTEXT, MEDIUMTEXT, y LONGTEXT que tratar de hacer como clave principal o índice. 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. Con plena BLOB o TEXT sin el valor de longitud, MySQL no está en condiciones de garantizar la unicidad de la columna, ya que la variable de tamaño y dinámica. So, when using BLOB or TEXT types as index, the value of N must be supplied so that MySQL can determine the key length. Por lo tanto, cuando se utiliza BLOB o tipos de texto como índice, el valor de N, se presentarán a fin de que MySQL puede determinar la longitud de la clave. However, MySQL doesn’t support limit on TEXT or BLOB. Sin embargo, MySQL no admite límite en el texto o BLOB. TEXT(88) simply won’t work. TEXTO (88) simplemente no funcionará.
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. El error también pop-up cuando intenta convertir una columna de la tabla de que no sean de texto y no de tipo BLOB como VARCHAR y ENUM en el texto o el tipo BLOB, con la columna ya se ha definido como único limitaciones o índice. The Alter Table SQL command will fail. La ALTER TABLE SQL comando fallará.
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. La solución al problema es quitar el texto o BLOB columna del índice único o limitación, o establecer otro campo como clave principal. 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. Si no puede hacerlo, y que quieren situar un límite en el texto o la columna BLOB, intente utilizar el tipo VARCHAR y coloque un límite de duración sobre el mismo. 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. De forma predeterminada, VARCHAR se limita a un máximo de 255 caracteres y su límite debe ser especificado implícitamente dentro de un soporte justo después de su declaración, es decir, VARCHAR (200) se limita a 200 caracteres, solamente.
Sometimes, even though you don’t use TEXT or BLOB related type in your table, the Error 1170 may also appear. A veces, a pesar de que no utilizan el texto o relacionadas con el tipo BLOB en la tabla, el error 1170 también puede aparecer. It happens in situation such as when you specify VARCHAR column as primary key, but wrongly set its length or characters size. Ocurre en situación como cuando se especifica la columna VARCHAR como clave principal, pero erróneamente establecer su longitud o tamaño de caracteres. 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 sólo acepta un máximo de 256 caracteres, de modo que nada como VARCHAR (512) obligará a MySQL para auto-convertir el VARCHAR (512) a un SMALLTEXT dato, que posteriormente fallará con error 1170 de longitud de clave si la columna se utiliza como principal o clave única o no-único índice. To solve this problem, specify a figure less than 256 as the size for VARCHAR field. Para resolver este problema, especifique una cifra de menos de 256 como el tamaño de campo VARCHAR.
IMPORTANT : This is a machine translated page which is provided "as is" without warranty. IMPORTANTE: Esta es una máquina traducido la página que se proporciona "TAL CUAL" SIN GARANTÍA. Machine translation may be difficult to understand. La traducción automática puede ser difícil de entender. Please refer to Por favor, consulte original English article artículo original Inglés whenever possible. siempre que sea posible.
Share and contribute or get technical support and help at Compartir y contribuir o recibir apoyo técnico y ayuda en My Digital Life Forums Mi vida digital foros .
Related Articles Artículos relacionados
- How to Convert Character Set and Collation of WordPress Database Cómo convertir conjunto de caracteres y colación de la base de datos de WordPress
- Installing Web Server in FreeBSD 6.0 with Apache 2.2, MySQL 5.0 and PHP 5 - Part 3 Instalación de servidor Web de FreeBSD 6.0 con Apache 2.2, MySQL 5.0 y PHP 5 - Parte 3
- Change and Reset MySQL root Password Cambio y Restablecer contraseña de root de MySQL
- Create New Table by Selecting Data from Other Tables with CREATE TABLE AS Crear una nueva tabla de selección de datos de otras tablas con CREATE TABLE como
- WordPress MySQL SQL Query Error in WPDB Class WordPress MySQL consulta SQL Error en la clase WPDB
- Easily Duplicate, Copy or Backup Tables in Oracle, PostgreSQL, DB2 and SQLite with Create Table As SQL Fácilmente duplicar, copiar o Tablas de copia de seguridad en Oracle, PostgreSQL, DB2 y SQLite con el cuadro Crear Como SQL
- Oracle PL/SQL ORA-00947 Not Enough Values Error Oracle PL / SQL ORA-00947 no bastan los valores de error
- Install Web Server in Windows XP with Apache2, PHP5 and MySQL4 - Part 4 Instalar Web Server en Windows XP con Apache2, PHP5 y MySQL4 - Parte 4
- Enable MySQL InnoDB Storage Engine Support in XAMPP Installation Activar MySQL motor de almacenamiento InnoDB apoyo en la instalación de XAMPP
- Change or Set MySQL Long Query Time Value for log-slow-queries Cambiar o Set MySQL largo valor del tiempo de consulta de log-slow-consultas

































August 30th, 2007 18:33 30 de agosto de 2007 18:33
Thanks for putting this up. Gracias por poner esto. I didn’t get the error and you saved me a lot o frustration. No he tenido el error y me ha guardado un lote o frustración. I’d put you in the ‘Goog people’ category anytime Me gustaría ponerle a usted en el "goog personas" categoría en cualquier momento
February 20th, 2008 02:45 20 de febrero, 2008 02:45
Thanks! Gracias! Very useful post. Muy útil puesto.
February 23rd, 2008 03:40 23 de febrero, 2008 03:40
Thanks for the post. Gracias por el puesto. Very helpful. Muy útil.
March 7th, 2008 04:15 7 de marzo, 2008 04:15
Thanks, very good defined Gracias, muy buenos definido
October 6th, 2008 03:50 6 de octubre, 2008 03:50
Thank you very much. Muchas gracias. I had this problem and you were a life saver! He tenido este problema y que son un ahorrador de vida!