php 解决方案:此表不包含唯一列。网格编辑、复选框、编辑、复制和删除功能不可用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18922503/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Resolution: This table does not contain a unique column. Grid edit, checkbox, Edit, Copy and Delete features are not available
提问by OldWest
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:
在 phpMyAdmin 中产生的错误是:
"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.
例如,只要您的所有 AI 或唯一标识符字段都是唯一的,那么您可以简单地更改表并确保这是主键并设置为唯一值。
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.
另一个表有多个作为主要字段的 AI int 值,但有多个相同类型的值。
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.
对此的简单解决方法是在表的末尾添加一列作为 Unique AI Int。基本上所有 MySQL 都在说它需要在每个记录中使用一个唯一值来区分行。
Hope this was helpful.
希望这是有帮助的。
回答by Do Nhu Vy
I have been faced with this problem.
The cause is your table doesn't have a primary key field.
And I have a simple solution: Set a field to primary key to specific field that suits your business logic.
For example, I have database thesis_db
and field thesis_id
, I will press button Primary (key icon) to set thesis_id
to become primary key field:
我一直面临这个问题。
原因是您的表没有主键字段。
我有一个简单的解决方案:将一个字段设置为适合您业务逻辑的特定字段的主键。
例如,我有数据库thesis_db
和字段thesis_id
,我将按按钮 Primary(键图标)设置thesis_id
为主键字段:
回答by dr fu manchu
This is not an error. PhpMyAdmin is just informing you, that there is no unique ID column in your result set. Depending on the type of query you sent, this is the desired behaviour.
这不是错误。PhpMyAdmin 只是通知您,您的结果集中没有唯一的 ID 列。根据您发送的查询类型,这是所需的行为。
It is not MySQL which is saying it needs a unique ID, if any combination of the columns in your result set is unique, the values of those columns can be used in an UPDATE or DELETE query. It is phpMyAdmin which says it does not have enough information to offer you the checkboxes and buttons you will normally see in a result set with unique ID.
不是 MySQL 说它需要一个唯一的 ID,如果结果集中的列的任何组合是唯一的,那么这些列的值可以在 UPDATE 或 DELETE 查询中使用。phpMyAdmin 表示它没有足够的信息为您提供您通常会在具有唯一 ID 的结果集中看到的复选框和按钮。
回答by Isaac Adni
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
.
只需创建一个新列,将 设置Name
为您喜欢的任何内容,设置Type
为INT
并选中显示 的框A_I
。
The
A_I
checkbox stands for AUTO_INCREMENT
, which essentially means that sequence numbers are assigned automatically in that new column (see below).
的
A_I
复选框表示AUTO_INCREMENT
,这实质上意味着序列号在该新列自动分配(见下文)。
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!
此列实质上用作 phpMyAdmin 从中删除行的参考。如有必要,请单击此新列的唯一按钮,尽管这对我来说是自动发生的。按照上述步骤操作后,您应该不再有错误消息,并且应该出现用于在 phpMyAdmin 中编辑行的按钮!
回答by Ravi
My case is different. This issue is only specific to PHPMyAdmin. I downloaded couple other admin tools (Adminer, MySQLWorkbench, HeidiSQL etc) and the same db works fine in all of those.
我的情况不同。此问题仅特定于 PHPMyAdmin。我下载了其他几个管理工具(Adminer、MySQLWorkbench、HeidiSQL 等),并且相同的数据库在所有这些中都可以正常工作。
I have all the indexes, primary key and unique keys defined and still get the error. I get this after I upgraded to MySQL 5.6 (did not face the same with the previous versions).
我定义了所有索引、主键和唯一键,但仍然出现错误。我升级到 MySQL 5.6 后得到这个(与以前的版本不同)。
Turns out PMA has issues with Table names in capital. PMA is not able to recognise keys with capital table names. Once I change them to small (ALTER TABLE mytable ENGINE=INNODB
-- I use INNODB -- does that for each table without changing anything else), I was able to access normally. I'm on a Windows system with UniformServer.
原来 PMA 有大写表名的问题。PMA 无法识别具有大写表名的键。一旦我将它们更改为小(ALTER TABLE mytable ENGINE=INNODB
-- 我使用 INNODB -- 在不更改任何其他内容的情况下为每个表执行此操作),我就能够正常访问。我在带有 UniformServer 的 Windows 系统上。
回答by Average Joe
This is how you get rid of that notice and be able to open those grid cells for edit
这就是您摆脱该通知并能够打开这些网格单元进行编辑的方法
1) click "STRUCTURE"
1)点击“结构”
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".
2) 转到您想要成为主键的字段(这通常是第一个),然后单击该字段的“PRIMARY”和“INDEX”字段并接受 PHPMyadmin 的弹出问题“OK”。
3) pad yourself in the back.
3)把自己垫在后面。
回答by snubbus
Adding this in the config.inc.php
file worked for me (under the last $cfg line):
在config.inc.php
文件中添加这个对我有用(在最后一个 $cfg 行下):
$cfg['RowActionLinksWithoutUnique'] = 'true';
$cfg['RowActionLinksWithoutUnique'] = 'true';
The file should be located in the phpMyAdmin
folder on your local computer
该文件应位于phpMyAdmin
本地计算机上的文件夹中
回答by Daniel Alsaker
An easy fix to this would be going to the SQL tab and just simply put in the code
一个简单的解决方法是转到 SQL 选项卡,只需简单地输入代码
ALTER TABLE `tablename`
ADD PRIMARY KEY (`id`);
Asuming that you have a row named id.
假设您有一个名为 id 的行。
回答by nonybrighto
In my case, the error occured in phpmyadmin version 4.5.1 when i set lower_case_table_names = 2 and had a table name with uppercase characters, The table had a primary key set to auto increment but still showed the error. The issue stopped when i changed the table name to all lowercase.
就我而言,当我设置 lower_case_table_names = 2 并且表名带有大写字符时,phpmyadmin 版本 4.5.1 中发生了错误,该表的主键设置为自动递增,但仍显示错误。当我将表名更改为全部小写时,问题停止了。
回答by zahra
I have been faced this problem.
我一直面临这个问题。
The cause is your table don't have a primary key field.
原因是您的表没有主键字段。
And I have a simple solution: Set a field to primary key to specific filed that suit with your business logic. For example, I have database thesis_db and field thesis_id, I will press button Primary (key icon) to set thesis_id to become primary key field
我有一个简单的解决方案:将一个字段设置为适合您业务逻辑的特定字段的主键。例如,我有数据库thesis_db和字段thesis_id,我将按下按钮Primary(键图标)将thesis_id设置为主键字段
回答by Jessa lauren
Make sure all your tables have one primary key. I forgot to add a primary key to one table and that solved this problem for me. :)
确保所有表都有一个主键。我忘了给一张表添加一个主键,这为我解决了这个问题。:)