13

PHPMyAdmin has just been upgraded by my server admin to v4.0.4.2.

Now I am unable to edit rows in the following table:

CREATE TABLE IF NOT EXISTS `product_options` (
  `product_id` int(10) NOT NULL,
  `option_id` int(10) NOT NULL,
  KEY `product_id` (`product_id`,`option_id`)
)

PHPMyAdmin just returns this error message when I browse data in the table:

This table does not contain a unique column. Grid edit, checkbox, Edit, Copy and Delete features are not available.

I don't want a unique column in this table, so how can I edit data? Is there a setting I can change?

Many thanks

MySQL v5.1.70

Dharman
  • 30,962
  • 25
  • 85
  • 135
SammyBlackBaron
  • 847
  • 3
  • 13
  • 31

7 Answers7

20

Without unique key, there is no way to differentiate between two same records which can exists. Therefore phpMyAdmin can not safely edit the table - you have no clue which of these would end up edited. Do you really want to have duplicate records in this table?

Michal Čihař
  • 9,799
  • 6
  • 49
  • 87
15

All you got to do is add a unique column like one called id with a index = PRIMARY like the pic, or if you have one already that is called id that are numbers just make it PRIMARY

enter image description here

zvzej
  • 6,276
  • 7
  • 33
  • 41
  • 1
    @PooyaEstakhri What I did was, first add a column to beginning of table, then choose this settings I called id (but you could already have it chosen) you can call it _id or newId, than if you already have a lot of entries select the A_I box that means Auto Increase so it will number all your passed entries from the first to the last on your actual table giving it a unique number and it will continue numbering all the new entries you enter into the table. that error is because is giving 0 values in all the entries and than is not unique. – zvzej Sep 09 '13 at 15:56
  • this should be accepted answer instead of that passive aggressive "solution" above – Robert Sinclair Oct 23 '18 at 05:54
3

You can just add a field that name is "id", and check A_I option.

1

Before checking the AUTO_INCREMENT option, check that the column is INT instead of VARCHAR.

Mike
  • 23,542
  • 14
  • 76
  • 87
T.Todua
  • 53,146
  • 19
  • 236
  • 237
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/low-quality-posts/13866135) – ADyson Oct 03 '16 at 09:56
  • @ADyson I don't see any links in the answer. – Mike Oct 04 '16 at 17:06
  • @Mike Sorry I must have clicked the wrong button in the Review. It's probably worth flagging as being just a comment rather than a full-featured answer though. – ADyson Oct 05 '16 at 08:49
1

I found a solution which might help someone in future, I had table with id, which was not primary key and not auto increment, i added temp column, made it primary and auto increment, then i edited the id column and then i removed the temp column, after that i changed id to primary and auto increment

runningmark
  • 738
  • 4
  • 13
  • 32
1

I had the same issue. In my own case I already had an id column. I dropped the column and recreated it; this time I made it a primary key and ticked A_I (ie Auto-Increment). Everything went fine.

Note: You can only do this if changing your IDs does not affect your work.

Obinna Nnenanya
  • 1,530
  • 14
  • 15
1

In my experience, you have more than 2 primary keys or you don't have any primary key.

CertainPerformance
  • 356,069
  • 52
  • 309
  • 320
jaro21
  • 25
  • 4