0

I have used this query to alter the table field:

 ALTER TABLE `recordstudent` CHANGE `DATE` `DATE` TEXT NOT NULL UNIQUE;

But I am getting this error:

   ERROR 1170 (42000): BLOB/TEXT column 'DATE' used in key specification without a key length

I am new to this and dont know what to do I googled it but found nothing which I could understand .Please help me to remove this error ,all I want this field as unique.

Navdroid
  • 4,453
  • 7
  • 29
  • 47
  • possible duplicate of [MySQL error: key specification without a key length](http://stackoverflow.com/questions/1827063/mysql-error-key-specification-without-a-key-length) – Manse Mar 24 '12 at 08:28
  • I think if the field is unique you must specify a number of chars – David Garcia Mar 24 '12 at 08:31

1 Answers1

1

You can't have a UNIQUE constraint on a column of unbounded size (TEXT is of "infinite" length).

Try this:

ALTER TABLE `recordstudent` CHANGE `DATE` `DATE` VARCHAR(1024) NOT NULL UNIQUE;

You'll have to pick a size that's big enough for your needs (but no bigger)

Bohemian
  • 412,405
  • 93
  • 575
  • 722