PDA

View Full Version : MySQL Error 1170


mlse
05-17-2005, 06:50 PM
Hi,

I am having problems with the UNIQUE keyword.

I have created a table as follows:

create table MyTable (
category int(32),
order int(32),
type_A text,
type_B text);

This is fine.

What I want to do, however, is to create the table as follows:

create table MyTable (
category int(32),
order int(32),
type_A text,
type_B text,
constraint UniqueABConstraint unique(type_A, type_B));

This, however, just throws up the error:

"ERROR 1170: BLOB column 'type_A' used in key specification without a key length".

When I look in the MySQL help file about this error, all it says is "This error is returned when a BLOB column is used in a key specification without a key length". Well, that's just about the most helpfull thing I've ever read in my life ...

Does anyone know what it means?? (In English!).

TIA,
Mike.

Kiwi
05-17-2005, 10:30 PM
It means that you can't have a free text field as a part of an index. You need to specify the length of the field. The reason is that an index effectively creates another table containing the fields you are indexing - the way SQL handles free text fields makes this rather difficult to do.

mlse
05-18-2005, 12:29 AM
Thanks!

(why doesn't the error blurb just say that!!!).