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'
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
Post a Comment