Query to remove unique or primary key from MYsql table

This is quick tutorial to removing unique or primary key from your MYSql table. Sometime we add unique key on table column to prevent from duplicate entry, But if in any case you need some duplicate data in your table like in my case i assigned unique key as company_name in my companies table to prevent from storing duplicate company name in my mysql table, But after some time i need to store duplicate company name because some companies has multiple address then i need to remove unique key from companies table, Then i use below query to alter company_name column. Using Mysql ALTER command you can modify table column property.


Removing unique key..

ALTER TABLE companies
DROP INDEX company_name;

Removing primary key..

ALTER TABLE companies
DROP INDEX 'PRIMARY';



If you like this post please don’t forget to subscribe my public notebook for more useful stuff

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.