Get the names of the indexes defined on the PENALTIES table.
mysql>
mysql>
mysql> CREATE OR REPLACE VIEW INDEXES
-> (INDEX_CREATOR, INDEX_NAME, CREATE_TIMESTAMP,
-> TABLE_CREATOR, TABLE_NAME, UNIQUE_ID, INDEX_TYPE) AS
-> SELECT DISTINCT UPPER(I.INDEX_SCHEMA), UPPER(I.INDEX_NAME),
-> T.CREATE_TIME, UPPER(I.TABLE_SCHEMA),
-> UPPER(I.TABLE_NAME),
-> CASE
-> WHEN I.NON_UNIQUE = 0 THEN 'YES'
-> ELSE 'NO'
-> END,
-> I.INDEX_TYPE
-> FROM INFORMATION_SCHEMA.STATISTICS AS I,
-> INFORMATION_SCHEMA.TABLES AS T
-> WHERE I.TABLE_NAME = T.TABLE_NAME
-> AND I.TABLE_SCHEMA = T.TABLE_SCHEMA;
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql>
mysql>
mysql> SELECT INDEX_NAME
-> FROM INDEXES
-> WHERE TABLE_NAME = 'PENALTIES'
-> AND TABLE_CREATOR = 'TENNIS';
Empty set, 1 warning (0.08 sec)
mysql>
Related examples in the same category