MySQL 如何在 phpmyadmin 表中删除多个主键?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21699600/
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
How can I drop multiple primary keys in phpmyadmin tables?
提问by anu_r
I am working with phpmyadmin.I created a table with one primary key and 5 fields. But now all the integer fields have turned into a primary key. I tried using drop command but it doesn't help. How can I remove all primary keys from the table?
我正在使用 phpmyadmin.I 创建了一个包含一个主键和 5 个字段的表。但是现在所有的整数字段都变成了主键。我尝试使用 drop 命令,但没有帮助。如何从表中删除所有主键?
回答by nKn
Just open up the Structure
tab on your phpmyadmin table. After the structure description, there should be a Indexes
section where you'll see all indexes, including your primary keys. There you'll be able to either modify or remove any primary key you may have defined.
只需打开Structure
phpmyadmin 表上的选项卡。在结构描述之后,应该有一个Indexes
部分,您将在其中看到所有索引,包括您的主键。在那里您将能够修改或删除您可能定义的任何主键。
---- EDIT ----
- - 编辑 - -
回答by Ajay Kumar
Try this
尝试这个
ALTER TABLE tablename MODIFY fieldname INT NOT NULL;
ALTER TABLE tablename DROP PRIMARY KEY;
回答by Y. Joy Ch. Singha
Here, i will tell you the Steps to do:
在这里,我会告诉你要做的步骤:
Step 1: Go to the Relation View.
步骤 1:转到关系视图。
Step 2: Indexes.
第 2 步:索引。
Step 3: You will find Keyname as PRIMARY.
第 3 步:您会发现 Keyname 为 PRIMARY。
Step 4: Drop the PRIMARY
第 4 步:删除 PRIMARY
Step 5: Ok.
第 5 步:好的。
Thanks.
谢谢。
Here all the Steps images, you can follow it for your easy.
这里有所有步骤图像,您可以轻松地遵循它。
回答by Khalil Hamani
You may have indexed a column as a FOREIGN KEY, in this cas you should delete this index and then you will be able to modify or delete your PRIMARY KEY.
您可能已将列索引为 FOREIGN KEY,在这种情况下您应该删除此索引,然后您将能够修改或删除您的 PRIMARY KEY。