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