MySQL FAQs
FAQs Categories
Client Server Commands
Database Structure
Table Types or Storage Engines
Indexes
SQL Statements
Table Joins
Funtions and Operators
Tricky Select Queries
Speed Up Queries
Data Back Up
General Questions
Errors
1PLs Company - #1Payday.Loans Agency - Loans online and near me $100-$2500 (Same Day)
Powered by MySQL
 
Home / Indexes / Question No: 68

How to remove or drop indexes in MySQL?

I want to  drop an already created index of my table.  Also I need to change primary key of the table.  Can you explain, how to remove or drop indexes in MySQL?

Answer No: 68

MySQL allows to drop existing INDEXES and PRIMARY KEYs.  For this MySQL provides ALTER TABLE and DROP statements. You can use ALTER TABLE statement to drop "normal" or "unique" indexes.

Syntax to drop an index by ALTER TABLE statement is like below:

ALTER TABLE tablename DROP INDEX index_name;

Take an example to drop an existing index:

ALTER TABLE buyers DROP INDEX fname_index;

To drop a primary key via ALTER TABLE syntax would be like below:

ALTER TABLE tablename DROP PRIMARY KEY;

Take an example to drop primary key:

ALTER TABLE buyers DROP PRIMARY KEY;

Related MySQL FAQs to the Above FAQ

How-to-get-existing-indexes-of-the-table-in-MySQL How to get existing indexes of the table in MySQL?

What-is-index-terminology-or-concept-and-how-does-index-work-in-MySQL What is index terminology or concept and how does index work in MySQL?

How-many-types-of-indexes-or-keys-are-in-MySQL How many types of indexes or keys are in MySQL?

What-is-single-column-index-or-key-in-MySQL What is single column index or key in MySQL?

What-is-multi-column-index-or-key-in-MySQL What is multi column index or key in MySQL?

What-is-partial-column-and-prefixed-column-index-or-key-in-MySQL What is partial-column and prefixed-column index or key in MySQL?

When-does-multi-column-index-come-into-use-in-MySQL When does multi column index come into use in MySQL?

What-are-best-practices-to-pick-columns-to-index What are best practices to pick columns to index?

What-are-advantages-and-disadvantages-of-indexes-in-MySQL What are advantages and disadvantages of indexes in MySQL?

Is-it-possible-to-apply-more-than-one-keys-on-a-single-column Is it possible to apply more than one keys on a single column?

What-is-foreign-key-in-MySQL What is foreign key in MySQL?

About FAQs: Recently Added FAQs

About MySQL FAQs: Site Map | Bookmark Us | Recommend this Site to Your Friend

Useful Links: Wikipedia.org | Oracle.com | w3schools.com | www.php.net | Github.com

© 2023  www.mysqlfaqs.net
All rights reserved.