user4582812
user4582812

Reputation: 621

Is there a way to know which index is the clustered index in MySQL?

I use the following command in MySQL to show the indexes of a table:

SHOW INDEX FROM someTable;

But the result doesn't indicate which index is the clustered index.

Is there a way to know which index is the clustered index?


Edit:

The following is the result of the command SHOW INDEX FROM sometable; (I executed the command CREATE INDEX someindex ON sometable(name); first):

enter image description here

Upvotes: 1

Views: 68

Answers (1)

nos
nos

Reputation: 229158

There's no a way to directly display that, you have to do it manually according to this description.

I.e. issue a show create table tablename, the clustered index is

  • the primary key
  • if three's no primary key, it's the first unique index where all the columns it cover is specified as NOT NULL

Otherwise the clustered index is an internal index using an internal rowid for innodb.

Upvotes: 1

Related Questions