×

MySQL Show index

This query helps to access and retrieve table information. This syntax displays the required index or all indexes of the table. It also displays the index type as per the storage engine.

Syntax

The basic syntax of the show index is given below.

SHOW INDEX from table name;

The show index syntax with database name is shown below.

SHOW INDEX FROM table name IN database name;

The show index syntax with database name is shown below.

SHOW INDEX IN table name FROM database name;

The show index syntax with database name is shown below.

SHOW INDEX FROM database.table;

The show index syntax with the WHERE clause is shown below.

SHOW INDEX from table name WHERE condition;

The show index syntax using the keys clause is shown below.

SHOW KEYS from table name IN database name;

Examples of the show index

1) Example: The basic show index example is shown below:

Execute the below query to see table indexes and their information.

mysql> SHOW indexes FROM index_table;

OUTPUT

MySQL Show Index

The above output image shows indexes from the table. The image shows the table name, unique key, key name, column name, index type, and table visibility.

2) Example: The basic show index with database example is shown below:

Execute the show indexes statement, including database and table name. You will use the required table name from a specific table name.The "show indexes" work with IN and FROM clauses.

mysql> SHOW indexes FROM index_table IN tutorial;

OUTPUT

MySQL Show Index

3) Example: The basic show index example with database name is shown below.

Execute the show indexes statement using database and table name.

mysql> SHOW indexes IN index_table FROM tutorial;

OUTPUT

MySQL Show Index

The above image shows indexes from the table. The image shows the table name, unique key, index name, column name, index type, collation, and table visibility.

4) Example: The basic show index example with database name is shown below.

Execute the show indexes statement with database and table name. Here we will use the required table name. The "show indexes" works with FROM clause and dot (.) symbol.

mysql> SHOW indexes FROM tutorial. index_table;

OUTPUT

MySQL Show Index

The above output image shows indexes from the table. The image shows the table name, unique key, sequence of the index, index name, column name, index type, and table visibility.

5) Example: The basic show index example with the WHERE clause is shown below.

Execute show indexes statement with WHERE clause. Here, you will use conditions on the index column. The condition applies to the visible column. The visible column assigns the "YES" condition.

mysql> SHOW indexes IN index_table FROM tutorial where visible = 'YES';

OUTPUT

MySQL Show Index

The above image shows indexes from the table. The output image shows the table name, sequence of the index, index name, column name, index type, and table visibility. The visible apply to the "YES" condition.

6) Example: The basic show index with key example is shown below.

Execute the following query to get the key name of the table. Here we will use the "keys" keyword instead of the index keyword.

mysql> SHOW keys FROM index_table IN tutorial;

OUTPUT

MySQL Show Index

The above output image shows indexes from the table. The image shows the table name, unique key, sequence of the index, key name, column name, index type, and table visibility. The key name is known as an index column.


Related Topics

MySQL Invisible Index

Invisible Index MySQL index decides an option to the availability of the index for the query optimizer. This index shows the visible and invisible options to displays the index column in...

3 minutes read.

MySQL SEC_TO_TIME() function

In this context, we will learn how we can use the MySQL SEC_TO_TIME() function with proper syntax and good examples. Introduction of MySQL SEC_TO_TIME() function This function in MySQL is used to...

2 minutes read.

find_in_set() function in MySQL

This Function is used for finding the position of a particular string from the list of strings. For suppose if the specified string is repeated multiple times, then this functions...

4 minutes read.

MySQL LOG2() function

In this context, we will learn how we can use the MySQL LOG2() function to calculate the Logarithm of a specific number with base 2 with proper syntax and examples. Introduction...

2 minutes read.

Clustered vs Non-Clustered Index

Clustered vs. Non-Clustered Index The difference between clustered and non-clustered index is the most famous question in the database-related interviews. Both indexes have the same physical structure and are stored as...

2 minutes read.

MySQL RADIANS() function

In this context, we will learn how we can use the MySQL RADIANS() function with proper syntax and good examples. Introduction of MySQL RADIANS() function RADIANS() function in MySQL is used to...

2 minutes read.

MySQL RIGHT() Function

In this context, we will learn how we can use the MySQL RIGHT() Function with proper syntax and good examples. Introduction of MySQL RIGHT() function The RIGHT() function in MySQL is used...

3 minutes read.

MySQL FIELD() function

In this context, we will learn how we can use the MySQL FIELD() function with proper syntax and good examples. Introduction of MySQL FIELD() function The index position of a mentioned value...

3 minutes read.

MySQL Features

Features of MySQL MySQL is a relational database management system (RDBMS): It is a collection of many programs and makes relations with many other programs. Easy to use MySQL database: MySQL...

2 minutes read.

MySQL Environmental Setup

The MySQL Environmental Setup MySQL is free, open-source, and cross-platform software, which can be downloaded from its official website. MySQL management system installs on Linux, macOS, and windows. MySQL requires a framework...

6 minutes read.

MySQL DATE_ADD() function

In this context, we will learn how we can use the MySQL DATE_ADD() function with proper syntax and good examples. Introduction of MySQL DATE_ADD() function In MySQL, the DATE_ADD() function is used...

3 minutes read.

MySQL Operators

MySQL Operators MySQL operator needs advanced operation on the table and its data. This operator works with the "WHERE" clause. MySQL operators are a statement to modify information. It helps to...

13 minutes read.

MySQL DATE_FORMAT() function

In this context, we will learn how we can use the MySQL DATE_FORMAT() function with proper syntax and good examples. Introduction of MySQL DATE_FORMAT() function DATE_FORMAT() function in MySQL is used to...

3 minutes read.

MySQL UPDATE JOIN

The UPDATE JOIN is a MySQL statement used to perform cross-table updates that means we can update one table using another table with the JOIN clause condition. The "update join"...

5 minutes read.

MySQL EXPORT_SET() function

In this context, we will learn how we can use the MySQL EXPORT_SET() function with proper syntax and good examples. Introduction of MySQL EXPORT_SET() function This function returns a string and shows...

3 minutes read.

MySQL SELF JOIN

This join links table with itself. The inner join, a self join, a right join, and a cross join are connected with two or more two tables. But, the "self...

4 minutes read.

MySQL Descending Index

Descending Index It is a type of index that stores key values in descending order. This query improves the performance of an index query. MySQL system displays the index as per...

3 minutes read.

MySQL FLOOR() function

In this context, we will learn how we can use the MySQL FLOOR() function with proper syntaxes and examples. Introduction of MySQL Floor() function: FLOOR() function in MySQL is used to return...

3 minutes read.

MySQL LOG() function

In this context, we will learn how we can use the MySQL LOG () function with proper syntax and good examples. Introduction of MySQL LOG() function The LOG() function in MySQL is...

3 minutes read.

MySQL Math Function

The math function operates numerical values and displays required number data. The math function finds out sin, cos, tan values. Here, you find out the absolute value, reminder, and logarithmic...

6 minutes read.