I am trying to view all foreign keys of my database and I have the following code to do that:
SELECT
tc.TABLE_NAME,
sc.COLUMN_NAME,
CONSTRAINT_NAME,
CONSTRAINT_TYPE
FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS as tc
inner join INFORMATION_SCHEMA.COLUMNS as sc
on sc.TABLE_NAME = tc.TABLE_NAME
order by tc.TABLE_NAME
But it seems to give more results than it should be. It gives around 30.000 result and it should be no more than 2000. What I am doing wrong. PS: I need this to return the table name, column name, column id and constraint type for further implementation in Laravel application.