2

Is there a mysql query which returns the relationship between tables?

I tried show full columns from <atable>; but it only returns meta data on columns excluding foreign keys.

Thank you in advance.

Asur
  • 1,949
  • 4
  • 23
  • 41
  • 1
    Possible duplicate of [How do I see all foreign keys to a table or column?](https://stackoverflow.com/questions/201621/how-do-i-see-all-foreign-keys-to-a-table-or-column) – Alexander Dec 20 '18 at 02:43

2 Answers2

2

Well SHOW CREATE TABLE yourTable should show the full create statement, which should include foreign key defintions. Beyond this, if you want to see a full graph of table relationships, you would probably have to use a tool outside of MySQL which specializes in doing that.

Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360
0

All of your keys are in the KEY_COLUMN_USAGE table and the type of constraint they are (primary key, Foriegn Key) should be in TABLE_CONSTRAINTS table

Paul Hebert
  • 296
  • 3
  • 8
  • I am using mysql 5.6 and could not locate any table with name `TABLE_CONSTRAINTS`. – Asur Dec 20 '18 at 03:15
  • Both of these tables are available in that version as well they are in the Information_schema. This article on stack exchange will demonstrate how to use it. https://dba.stackexchange.com/questions/93919/mysql-list-databases-with-tables – Paul Hebert Dec 20 '18 at 05:01