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'