List:General Discussion« Previous MessageNext Message »
From:Gerald Clark Date:November 5 1999 2:03pm
Subject:Re: Alter table with UNIQUE INDEX
View as plain text  
Vivek Khera wrote:

> >>>>> "JT" == Jeff Thies <cyberjeff@stripped> writes:
>
> JT>   I've got a table with duplicate entries, I'd like to alter the table
> JT> so that I have a unique index (and then use REPLACE INTO).
>
> JT>   What happens to my rows that have the same value that are now in a
> JT> unique index???
>
> When you alter your table to have the unique index, it will complain
> and then refuse to generate said index.  That is, you need to
> alter/delete those rows before the index will be created.  That said,
> running the alter table command to add the index helps find those
> rows.
>

alter table tablename IGNORE add UNIQUE  indexname

will keep the first record for the index record created.  The others will be
disposed of.

see  section 7.7 of the manual.


Thread
Alter table with UNIQUE INDEXJeff Thies4 Nov
  • Re: Alter table with UNIQUE INDEXVivek Khera4 Nov
  • Re: Alter table with UNIQUE INDEXGerald Clark5 Nov