MySQL: making a column unique?

Viewed 69401

I have a table that is in production. I realize that some of the columns should be unique. Is it safe to go into phpMyAdmin and change those columns to make it unique?

ALTER TABLE  `foo` ADD UNIQUE ( `bar` )
5 Answers

I had this problem and my values were not unique. I also couldn't find an easy way to edit this problem in PHPMyAdmin. Here's how I solved it:

  1. I clicked into the table I needed to update

  2. I exported the table, changing it to be a CSV export and then edited it manually to update the non-unique values.

  3. Making sure I was still in the table I had exported (because I wanted to keep the headers intact), I imported my newly saved CSV

Hope that saves someone some time in the future.

Related