使用information_schema.table_constraints表获取每个表上定义的约束的名称:
information_schema.table_constraints
select * from information_schema.table_constraints where constraint_schema = 'YOUR_DB'
使用information_schema.key_column_usage表获取这些约束中的字段:
information_schema.key_column_usage
select * from information_schema.key_column_usage where constraint_schema = 'YOUR_DB'
如果您要讨论外键约束,请使用information_schema.referential_constraints:
information_schema.referential_constraints
select * from information_schema.referential_constraints where constraint_schema = 'YOUR_DB'
使用
information_schema.table_constraints
表获取每个表上定义的约束的名称:使用
information_schema.key_column_usage
表获取这些约束中的字段:如果您要讨论外键约束,请使用
information_schema.referential_constraints
: