×

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 Truncate() Function

In this context, we will learn how we can use the MYSQL TRUNCATE function to truncate a number to a mentioned number of decimal places. Syntax of MySQL Truncate Function A number...

2 minutes read.

MySQL Stored Procedure

MySQL creates the "stored procedure" function to operate database information. You can use parameters, blocks, and statements to create a new procedure. The procedure requires a database table to use...

3 minutes read.

MySQL Triggers

MySQL trigger is a function of the stored procedure to respond to the system program. This function responds and runs any data table event automatically. You can use it for...

5 minutes read.

MySQL ISNULL function

This function is used to check the null value in table data. It returns the result in a Boolean form. If table data is null, then the output becomes 1....

2 minutes read.

MySQL MONTHNAME() function

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

3 minutes read.

MySQL DAY() function

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

2 minutes read.

MySQL FROM_BASE64() function

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

2 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 logical conditions

MySQL logical conditions Introduction MySQL handles data with clauses, operators, and conditions. The logical condition is used to compare information and returns the required output. This condition applies logic to MySQL expressions...

7 minutes read.

MySQL Create index

An index creation helps to make a row of the table unique. The index operates and handles table data quickly. MySQL index requires NOT NULL column constraint. The index column...

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 LOCATE() function

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

3 minutes read.

MySQL Composite Index

Composite Index A composite index is an index that is used on multiple columns. MySQL management system manages multiple columns simultaneously. Therefore, the single index contains multiple columns in one query...

3 minutes read.

MySQL RTRIM() function

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

2 minutes read.

MySQL function

MySQL function is a piece of program to perform some specific task. Here we pass a parameter and then return a single value. MySQL function mainly supports string, numeric, conditional,...

9 minutes read.

MySQL MAX function

The MAX function is a type of aggregation function that determines the maximum value of the table data. This function works on numerical data type values. If the table displays...

4 minutes read.

MySQL Control flow function

The control flow function uses values or operands for logical operations. These functions can works on single and multiple conditions. The control flow function is based on the Boolean expression....

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: Entity-Relationship Model

Entity-Relationship Model Entity-Relationship model or E R model is used to create a relationship between different attributes or entities. It describes the structure of the database with the help of the...

5 minutes read.

MySQL Error 1046 - No Database Selected

What is MySQL? MySQL is a Relational Database Management System (RDBMS). SQL in MySQL is the abbreviation of "Structured Query Language", which Oracle developed it in 1995. It is one of...

1 minute read.