1

I'm selecting my table schema data like this

SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE,CHARACTER_MAXIMUM_LENGTH
FROM information_schema.columns
WHERE table_schema = DATABASE()
ORDER BY table_name, ordinal_position

I'm getting all column related data in that. How can I get whether a column is participating in a primary key or not with Y or N like this

ColumnName Primary key

t1 Y t2 N

ChathurawinD
  • 756
  • 1
  • 13
  • 35
  • Put `EXPLAIN` in the front of your query, then you will find out which indexes are being used and in which order – Paul Stanley Nov 05 '15 at 09:02
  • This is a duplicate although the other question is about SQL Server. The information_schema however is part of the SQL ANSI-Standard '92 and it works the same for MySQL. – fancyPants Nov 05 '15 at 09:05

0 Answers0