- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can I view the indexes I have set up in MySQL?
To view the indexes, you can use SHOW command.
Following is the syntax −
show index from yourTableName;
Let us first create a table −
mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, FirstName varchar(20), LastName varchar(20) ); Query OK, 0 rows affected (0.46 sec)
Following is the query to create an index −
mysql> create index id_FirstName on DemoTable(Id,FirstName); Query OK, 0 rows affected (0.52 sec) Records : 0 Duplicates : 0 Warnings : 0
Following is the query to view the indexes I have set up in MySQL −
mysql> show index from DemoTable;
This will produce the following output displaying the index as well −
+--------------+------------+--------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+ | Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | Visible | +--------------+------------+--------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+ | DemoTable | 0 | PRIMARY | 1 | Id | A | 0 | NULL | NULL | | BTREE | | | YES | | DemoTable | 1 | id_FirstName | 1 | Id | A | 0 | NULL | NULL | | BTREE | | | YES | | DemoTable | 1 | id_FirstName | 2 | FirstName | A | 0 | NULL | NULL | YES | BTREE | | | YES | +--------------+------------+--------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+ 3 rows in set (0.26 sec)
- Related Articles
- How can I view cascades in MySQL?
- How can I dynamically set the position of view in android?
- How do I create a view in MySQL?
- Show/view indexes in a MySQL Database
- How can I get up early in the morning?
- I have a startup but sometimes I lack motivation and feel like giving up. How can I keep myself motivated throughout?
- What if I forgot to set Auto Increment? Can I set it later in MySQL?
- How do I view the auto_increment value for a table in MySQL?
- What are the things I have to do every morning when I wake up?
- How do I set up C/C++ on Eclipse in Windows?
- How do I set the timezone of MySQL?
- How can I clone/duplicate the table along with its data, trigger and indexes?
- How can I set a MySQL database to use MyISAM by default?
- How can I set the row height in Tkinter TreeView?
- How do I display the indexes of a collection in MongoDB?

Advertisements