I have a mysql database that has 250 tables.
I would like to run a query to retrieve:
tableName ; FieldName ; ConstaintName (Primary or foreign key).
I could use information_schema.TABLE_CONSTRAINTS to retrieve the constarint type
but for the inner join I have no idea what should I use.
What is the best approach to achieve this task?
EDIT:
not Constraint name. Should be CONSTRAINT_TYPE instead of ConstaintName. So we should be able to see (Primary or foreign key) only.
Best Answer
You can use INFORMATION_SCHEMA KEY_COLUMN_USAGE table.
Updated code based on OP's requirement: