List:General Discussion« Previous MessageNext Message »
From:Harald Fuchs Date:November 22 2005 9:31am
Subject: Re: UNIQUE constraint, proper use
View as plain text  
In article <4382953B.4080905@stripped>,
Ferindo Middleton Jr <fmiddleton@stripped> writes:

> I have this SQL statement:
> CREATE TABLE rooms (
>                          id                SERIAL,
>                          room_name       TEXT UNIQUE,
>                          location      TEXT,
>                          last_updated  TIMESTAMP DEFAULT
> CURRENT_TIMESTAMP NOT NULL,
>                          last_user_updated    TEXT,
>              PRIMARY KEY(id)
> );

> When I run this I get the following error:
> ERROR 1170 (42000): BLOB/TEXT column 'room_name' used in key
> specification without a key length

MySQL can index only the first N chars of a BLOB or TEXT column; you
must supply the value of N.

> I'm more used to PostgreSQL and when I run this command there, I don't
> get this error message.

Even in PostgreSQL it's not always beneficial to put a long bytea
column into an index.  Can't you use a surrogate key?

Thread
UNIQUE constraint, proper useFerindo Middleton Jr22 Nov
  • Re: UNIQUE constraint, proper usePaul DuBois22 Nov
  • Re: UNIQUE constraint, proper useHarald Fuchs22 Nov
  • Re: UNIQUE constraint, proper useMartijn Tonies22 Nov