0

I am having problems with modifying an existing table in MySQL. When adding a new column, MySQL complains about indexing on an existing column. Here is what I am seeing:

mysql> CREATE TABLE test (name TINYTEXT, KEY(name(255)));
Query OK, 0 rows affected (0.08 sec)

mysql> ALTER TABLE test ADD name2 TINYTEXT;
ERROR 1170 (42000): BLOB/TEXT column 'name' used in key specification without a key length

What am I doing wrong? I already have a key length on the key specification, and I'm not changing it anyways.

Bruce
  • 63
  • 4
  • I can't reproduce it: http://www.sqlfiddle.com/#!2/ba6ae – Barmar Oct 25 '13 at 02:53
  • I am able to do this without error in MySQL 5.1. Not sure why you are getting an error. Maybe try using VARCHAR(255) instead of TINYTEXT – Charlie Martin Oct 25 '13 at 02:59
  • Perhaps the problem is fixed in MySQL 5.5.32 that SQL Fiddle is running. I'm stuck with 5.1 for now. I'm currently running 5.1.70, but I looked at the change logs, but don't see any relevant bug fixes in the later releases. – Bruce Oct 25 '13 at 03:01
  • @CharlieMartin It appears to be dependent on the charset. If I create the table with `CHARSET=latin1`, it works, but with `CHARSET=utf8`, it fails. – Bruce Oct 25 '13 at 03:13

0 Answers0