
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Remove Index from a MySQL Table
To remove index from a MySQL table, the syntax is as follows −
alter table yourTableName drop index `yourIndexName`;
Let us first create a table −
Mysql> create table DemoTable1469 -> ( -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> StudentName varchar(40), -> StudentAge int -> ); Query OK, 0 rows affected (0.78 sec)
Following is the query to add index on column name −
mysql> create index `Student Name_Index` on DemoTable1469(StudentName); Query OK, 0 rows affected (0.33 sec) Records: 0 Duplicates: 0 Warnings: 0
Let us check the table description −
mysql> desc DemoTable1469;
This will produce the following output −
+-------------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------+-------------+------+-----+---------+----------------+ | StudentId | int(11) | NO | PRI | NULL | auto_increment | | StudentName | varchar(40) | YES | MUL | NULL | | | StudentAge | int(11) | YES | | NULL | | +-------------+-------------+------+-----+---------+----------------+ 3 rows in set (0.00 sec)
Following is the query to remove index −
mysql> alter table DemoTable1469 drop index `Student Name_Index`; Query OK, 0 rows affected (0.23 sec) Records: 0 Duplicates: 0 Warnings: 0
Let us check the table description once again −
mysql> desc DemoTable1469;
This will produce the following output −
+-------------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------+-------------+------+-----+---------+----------------+ | StudentId | int(11) | NO | PRI | NULL | auto_increment | | StudentName | varchar(40) | YES | | NULL | | | StudentAge | int(11) | YES | | NULL | | +-------------+-------------+------+-----+---------+----------------+ 3 rows in set (0.00 sec)
Advertisements