PDA

View Full Version : Can I have both 'Unique' & 'Index' on a column?


student
04-16-2007, 04:31 AM
Hello,
I have a mysql table
and I use wizmysqladmin to make modifications to it.

I have declared 'Index' on a column while setting up the table.

later, I understood that elements in that column are 'unique'.
So, I have declared 'unique' on that column.

Now, that column is having both 'index' and 'unique'

is it ok or shall I remove one of the two?

Thank you.

guelphdad
04-16-2007, 05:52 AM
unique is an index so you now have two indexes on the column, only one of which can be used at a time. you are using up extra storeage space.

note that when you have an index on a column, you can merely ALTER the index to make it unique without having added a second index.

student
04-18-2007, 02:55 PM
Hello guelphdad,
thank you for this valuable information.
I will delete 'Index' and keep 'unique'
thanks