MySQL Error 1170 (42000): BLOB/TEXT Column Used in Key Specification Without a Key Length MySQL Error 1170 (42000): BLOB / TEXT Coluna Utilizado em Key Especificação Sem uma chave Comprimento
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: Ao criar uma nova tabela ou modificar uma tabela existente com chaves primárias, únicas restrições e índices, ou quando a definição de um novo índice com ALTER TABLE manipulação declaração no banco de dados MySQL, o seguinte erro pode ocorrer e proibir a partir de completar o comando:
ERROR 1170 (42000): BLOB/TEXT column ‘field_name’ used in key specification without a key length ERROR 1170 (42000): BLOB / TEXT coluna 'field_name' usado na chave sem especificação uma chave comprimento
The error happens because MySQL can index only the first N chars of a BLOB or TEXT column. O erro ocorre porque o MySQL só pode indexar os primeiros N caracteres de uma coluna BLOB ou TEXT. 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. Portanto, o erro acontece principalmente quando existe um campo / tipo de texto ou coluna BLOB ou TEXT ou pertence a esses tipos BLOB como TINYBLOB, MEDIUMBLOB, LONGBLOB, TINYTEXT, MEDIUMTEXT, e LONGTEXT que você tente fazer como chave primária ou í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. Com pleno BLOB ou TEXT sem o comprimento valor, o MySQL é incapaz de garantir a unicidade da coluna como ele é de tamanho variável e 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. Portanto, ao utilizar tipos BLOB ou TEXT como índice, o valor de N devem ser fornecidas de forma que o MySQL pode determinar as principais comprimento. However, MySQL doesn’t support limit on TEXT or BLOB. No entanto, o MySQL não suporta limite para TEXT ou BLOB. TEXT(88) simply won’t work. TEXTO (88) simplesmente não funciona.
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. O erro também irá aparecer quando você tentar converter uma coluna de tabela não-texto e não-tipo BLOB como ENUM em VARCHAR e TEXT ou BLOB tipo, com a coluna já sido definido como únicas restrições ou índice. The Alter Table SQL command will fail. O comando SQL ALTER TABLE irá falhar.
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. A solução para o problema é remover a coluna TEXT ou BLOB ou a partir do índice único constrangimento, ou definir um outro campo como chave primária. 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. Se você não puder fazer isso, e querer colocar um limite para a coluna TEXT ou BLOB, tente usar tipo VARCHAR e coloque um limite de comprimento sobre o mesmo. 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. Por padrão, VARCHAR é limitado a um máximo de 255 caracteres e seu limite deve ser especificado implicitamente dentro de uma faixa direita depois da sua declaração, ou seja, VARCHAR (200) que irá limitar a apenas 200 caracteres.
Sometimes, even though you don’t use TEXT or BLOB related type in your table, the Error 1170 may also appear. Às vezes, mesmo que você não pode usar TEXT ou BLOB tipo relacionados na sua tabela, o erro 1170 também pode aparecer. It happens in situation such as when you specify VARCHAR column as primary key, but wrongly set its length or characters size. Ela acontece em situações como quando você precisar VARCHAR coluna como chave primária, mas erradamente definir a sua duração ou caracteres tamanho. 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ó aceita até 256 caracteres, então qualquer coisa como VARCHAR (512) irá vigor MySQL para converter a auto-VARCHAR (512) para um SMALLTEXT dados, que posteriormente falhar com erros em 1170 comprimento chave se a coluna é usado como primário chave ou único ou não-único índice. To solve this problem, specify a figure less than 256 as the size for VARCHAR field. Para resolver este problema, especificar um valor inferior a 256 como o tamanho de campo VARCHAR.
IMPORTANT : This is a machine translated page which is provided "as is" without warranty. IMPORTANTE: Esta é uma página traduzida máquina que é fornecida "como está" sem garantia. Machine translation may be difficult to understand. A tradução automática pode ser difícil de compreender. Please refer to Por favor, consulte a original English article Inglês original article whenever possible. sempre que possível.
Share and contribute or get technical support and help at Compartilhe e contribuir ou obter suporte técnico e ajudar a My Digital Life Forums Minha vida digital Fóruns .
Related Articles Artigos relacionados
- How to Convert Character Set and Collation of WordPress Database Como converter conjunto de caracteres e collation de banco de dados WordPress
- Create New Table by Selecting Data from Other Tables with CREATE TABLE AS Criar uma nova tabela, selecionando dados de outras tabelas com criar tabela como
- Installing Web Server in FreeBSD 6.0 with Apache 2.2, MySQL 5.0 and PHP 5 - Part 3 Instalando Web Server no FreeBSD 6,0 a 2,2 Apache, MySQL e 5,0 PHP 5 - Parte 3
- Install Web Server in Windows XP with Apache2, PHP5 and MySQL4 - Part 4 Instalar Web Server no Windows XP com Apache2, PHP5 e MySQL4 - Parte 4
- Change and Reset MySQL root Password Mudança e Reset MySQL raiz Senha
- ORA-02449 Oracle Drop Table Error ORA-02449 Oracle gota tabela erro
- Enable MySQL InnoDB Storage Engine Support in XAMPP Installation Ativar MySQL motor de armazenamento InnoDB apoio na instalação XAMPP
- Easily Duplicate, Copy or Backup Tables in Oracle, PostgreSQL, DB2 and SQLite with Create Table As SQL Facilmente duplicar, copiar ou fazer backup Quadros em Oracle, PostgreSQL, e DB2 com SQLite Como Criar tabela SQL
- WordPress MySQL SQL Query Error in WPDB Class WordPress MySQL consulta SQL erro na classe WPDB
- Oracle PL/SQL ORA-00947 Not Enough Values Error Oracle PL / SQL ORA-00947 não basta valores erro













August 30th, 2007 18:33 30 de agosto de 2007 18:33
Thanks for putting this up. Obrigado por colocar este tipo de ligações. I didn’t get the error and you saved me a lot o frustration. Eu não recebi o erro e você salvou-me um lote ou frustração. I’d put you in the ‘Goog people’ category anytime Eu não colocá-lo na "GOOG pessoas" categoria qualquer momento
February 20th, 2008 02:45 20 de fevereiro de 2008 02:45
Thanks! Obrigado! Very useful post. Muito útil post.
February 23rd, 2008 03:40 23 de fevereiro de 2008 03:40
Thanks for the post. Graças ao cargo. Very helpful. Muito útil.
March 7th, 2008 04:15 De 7 de março de 2008 04:15
Thanks, very good defined Obrigado, muito bem definida