Resolution: This table does not contain a unique c

2019-09-16 12:06发布

This is not a question but a self generated problem/question and solution that I found working. I thought it would be decent courtesy to share since there was not a complete working solution I could find.

The error generated in phpMyAdmin is:

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

There are several working solutions depending on your exact scenario.

For example, as long as all of your AI or Unique identifier field are unique then you can simply alter the table and ensure this is the Primary key and set to unique value.

I solved this with this solution on one of my tables.

The other table had multiple AI int values that were the Primary field, but there were multiple values of the same kind.

The simple fix for this was to just add a column to the end of the table as Unique AI Int. Basically all MySQL is saying is it needs a unique value in each record to differentiate the rows.

Hope this was helpful.

15条回答
相关推荐>>
2楼-- · 2019-09-16 12:41

the code that worked for me

ALTER TABLE `table name`
ADD COLUMN `id` INT NOT NULL AUTO_INCREMENT,
ADD PRIMARY KEY (`id`);
查看更多
Anthone
3楼-- · 2019-09-16 12:45

An easy fix to this would be going to the SQL tab and just simply put in the code

ALTER TABLE `tablename`
ADD PRIMARY KEY (`id`);

Asuming that you have a row named id.

查看更多
欢心
4楼-- · 2019-09-16 12:48

I got this error when trying to modify directly after running Query. Turns out, after making a view from that exact same query, I was able to modify the values.

查看更多
趁早两清
5楼-- · 2019-09-16 12:49

This is how you get rid of that notice and be able to open those grid cells for edit

1) click "STRUCTURE"

2) go to the field you want to be a primary key (and this usually is the 1st one ) and then click on the "PRIMARY" and "INDEX" fields for that field and accept the PHPMyadmin's pop-up question "OK".

3) pad yourself in the back.

查看更多
虎瘦雄心在
6楼-- · 2019-09-16 12:50

This for me was resolved by re-exporting the data from original source DB and then importing it into the mirror DB.

查看更多
淡お忘
7楼-- · 2019-09-16 12:54

Simply create a new column, set the Name to whatever you like, set the Type to INT and check the box that says A_I.

diagram The A_I checkbox stands for AUTO_INCREMENT, which essentially means that sequence numbers are assigned automatically in that new column (see below).

 column1 | column2 | id
-----------------------
 value   | value   | 1
-----------------------
 value   | value   | 2
-----------------------
 value   | value   | 3
-----------------------
 value   | value   | 4

This column essentially acts as a reference for phpMyAdmin to delete rows from. If necessary, click on the unique button for this new column, although this happened automatically for me. After following the above steps, you should no longer have the error message and buttons should appear for editing rows in phpMyAdmin!

查看更多
登录 后发表回答