Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I drop multiple primary keys in phpmyadmin tables?

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?

like image 496
anu_r Avatar asked Feb 11 '14 10:02

anu_r


People also ask

How can I drop multiple primary keys in MySQL?

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.

Can we have multiple primary keys in a table?

Each table can only have one primary key. Access can automatically create a primary key field for you when you create a table, or you can specify the fields that you want to use as the primary key.

Can we have multiple primary keys on multiple columns in a table?

A table can have only ONE primary key; and in the table, this primary key can consist of single or multiple columns (fields).


2 Answers

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.

---- EDIT ----

enter image description here

like image 130
nKn Avatar answered Oct 17 '22 09:10

nKn


Try this

ALTER TABLE tablename MODIFY fieldname INT NOT NULL;
ALTER TABLE tablename DROP PRIMARY KEY;
like image 42
Ajay Kumar Avatar answered Oct 17 '22 10:10

Ajay Kumar