使用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
: