在phpMyAdmin中没有唯一列的表 [英] Table with no unique column in phpMyAdmin
问题描述
这是我的桌子:
CREATE TABLE group_edits (
vfile_id bigint(20) unsigned NOT NULL,
editor_id int(10) unsigned NOT NULL,
edits text
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
没有唯一索引,因为一个editor_id可以编辑多个vfile_id,而一个vfile_id也可以由多个editor_ids编辑.
There is no unique index, because one editor_id can edit multiple vfile_ids, also one vfile_id can be edited by multiple editor_ids.
phpMyAdmin 4.1.6不允许我编辑此表,说:
phpMyAdmin 4.1.6 does not allow me to edit this table saying:
Current selection does not contain a unique column. Grid edit, checkbox, Edit, Copy and Delete features are not available.
现在,这让我感到事情像这样的桌子有什么问题吗?当您采用editor_id和vfile_id的值时,行是唯一的,而单独的列都不是唯一的.
Now it makes me thing is there anything wrong with the table like this? Rows are unique when you take a value of editor_id AND vfile_id while none of the columns alone is unique.
我知道要修复此问题,我可以添加
I know that to fix it I could add
`ID` int(11) NOT NULL AUTO_INCREMENT,
但是它不能反映我的数据库模式的设计,我想避免添加一些使phpMyAdmin工作的技巧.
but it does not reflect the design of my database schema and I would like to avoid adding tricks just to make phpMyAdmin work.
我的数据库设计错误还是phpMyAdmin?
Is my database design wrong or is it phpMyAdmin?
推荐答案
如果您完全确定可以创建(editor_id,vfile_id)的唯一主复合键,请继续执行此操作.
If you are absolutely sure you can make a unique primary compound key of (editor_id, vfile_id), go ahead and do that.
ALTER TABLE group_edits ADD PRIMARY KEY (editor_id, vfile_id)
明智的做法是先使用phpmyadmin转储该表的副本,以便在将表弄乱时可以将其还原.
You'd be wise to use phpmyadmin to dump a copy of the table first, so you can restore it if you mess it up.
那应该允许phpmyadmin允许您更新表中的行.
That should permit phpmyadmin to let you update rows in the table.
这篇关于在phpMyAdmin中没有唯一列的表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!