資料庫中的約束條件清單
P粉752826008
P粉752826008 2023-08-22 15:07:48
0
1
455
<p>如何從MySQL資料庫取得所有約束的清單? </p>
P粉752826008
P粉752826008

全部回覆(1)
P粉327903045

使用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'
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!