I have a large database with over 150 tables that I've recently been handed. I'm just wondering if there is an easy way to view all foreign key constraints for the entire DB instead of on a per-table basis.
相关问题
- sqlyog export query result as csv
- NOT DISTINCT query in mySQL
- NOT DISTINCT query in mySQL
- MySQL: conduct a basic search
- Flush single app django 1.9
Query this code
You will get constraint_name, and filter the table_schema which is the list of
database
.Look at This
SQL:
Output:
You can use the
INFORMATION_SCHEMA
tables for this. For example, theINFORMATION_SCHEMA TABLE_CONSTRAINTS
table.Something like this should do it:
This is what I prefer to get useful informations:
The currently accepted answer by user RedFilter will work fine if you have just 1 database, but not if you have many.
After entering
use information_schema;
use this query to get foreign keys forname_of_db
:Use this query to get foreign keys for
name_of_db
saved to world-writeable fileoutput_filepath_and_name
: