mySQL unique grey or blue icon? [SOLVED]

Hi,
When I try to INSERT a question number that has already been used, I get the following error,

[16-Feb-2015 14:02:31 America/Denver] PHP Fatal error:  Uncaught exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '22' for key 'question'' in /home2/shanegib/public_html/artgibney/admin/teachingpoints/index.php:73
Stack trace:
#0 /home2/shanegib/public_html/artgibney/admin/teachingpoints/index.php(73): PDOStatement->execute()
#1 {main}
  thrown in /home2/shanegib/public_html/artgibney/admin/teachingpoints/index.php on line 73

So it seems that the question column is set only accept unique values. Therefore I am trying to turn off unique on that column.

I am using phpMyAdmin. Below is my table structure,

As you can see id is underlined, so i know that is the primary column. I understand that the yellow keysindicate which columns could be set to be primary.
The U icon to the right of the grey or yellow key is slightly grey for columns: id, subtopic, topic and tp. These columns all also have yellow keys. Except the question column which has a yellow key and a grey U.
Does the grey U indicate which columns are unique?
And if so how can I make the ‘question’ column not unique. The column will just hold a int from 1 to 25.
Thanks,
Shane

Hi,
I have solved this problem, by renaming the column ‘question’ to ‘questionprev’. Then I created another column called question. Making sure that it was not unique and copied over the values from ‘questionprev’ to ‘question’. Now when I add a row, the ‘question’ does not need to be unique.
Thanks,
Shane

1 Like

No, seems I haven’t solved this. The problem persists.
Shane

Hi,
I finally got rid of the grey U icon and got it to a blue U icon.
I was trying to use SQL to look at the table using,

DESCRIBE table

Then to drop the unique on the column, I was using

alter table mytable drop index mycolumn;

But this wasn’t working.
So I looked at the indexes and deleted them, well all except the id primary index.
Now all seems to be working fine.
Thanks,
Shane

1 Like

@ofeyofey

I hope that this time the problem is really solved and you don’t have further problems. I do apologise if you felt that we didn’t pay enough attention to you. I confess that I can’t remember how my PHPMyAdmin shows things… I always work with direct connection and black screen.

Well done and do something nice to celebrate that you sorted it out :slight_smile:

And thank you for sharing the solution. That’s true community spirit

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.