How to show composite index in mysql?

Member

by addison , in category: MySQL , a year ago

How to show composite index in mysql?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by jasen_gottlieb , a year ago

@addison 

To show a composite index in MySQL, you can use the SHOW INDEX statement. Here is the syntax:

1
SHOW INDEX FROM [table_name];


For example, if you have a table called customers with a composite index, you can use the following command to show the index:

1
SHOW INDEX FROM customers;


This command will display information about all the indexes in the specified table, including the composite index.


The output will contain several columns, but the most important ones for determining if an index is composite are:

  • Table: The name of the table where the index is defined.
  • Non_unique: A value of 0 indicates that the index is unique (not a composite index) and 1 indicates that it is non-unique (a composite index).
  • Key_name: The name of the index.
  • Column_name: The name of the column(s) included in the composite index.
  • Seq_in_index: The position of the column within the composite index.


By checking the Non_unique column, you can identify if an index is composite or not. If the value is 1, it means the index is non-unique (composite).