Show indexes for a MySQL table

SELECT COLUMN_NAME, COLUMN_KEY

FROM INFORMATION_SCHEMA.COLUMNS

WHERE TABLE_SCHEMA = 'db'

AND TABLE_NAME = 'goyun'

AND COLUMN_KEY != ''




For primary key:




SELECT COLUMN_NAME, COLUMN_KEY

FROM INFORMATION_SCHEMA.COLUMNS

WHERE TABLE_SCHEMA = 'db'

AND TABLE_NAME = 'goyun'

AND COLUMN_KEY != 'PRI'

Comments

Popular posts from this blog

Check MySQL query history from command line