1. 程式人生 > 實用技巧 >SQL server 獲取各種 約束資訊

SQL server 獲取各種 約束資訊

https://bbs.csdn.net/topics/380103485 --獲取約束資訊 select*frominformation_schema.constraint_column_usage---可以獲取指定資料庫中的所有約束的資訊以及約束與列的對應關係 go select*frominformation_schema.constraint_table_usage---查詢結果中只包含表和約束的對應關係,並沒有約束對應的列資訊 go select*frominformation_schema.table_constraints---查詢結果中只包含表和約束的對應關係,並沒有約束對應的列資訊
go select*frominformation_schema.key_column_usage---可以獲取指定資料庫中的所有鍵約束的列資訊,包括主鍵約束中的主鍵列,唯一約束中的唯一鍵列和外來鍵約束中的引用列 go select*fromsys.key_constraints----獲取約束資訊 select*fromsys.foreign_keys--獲取表中的外來鍵約束 select*fromsys.foreign_key_columns--獲取外來鍵約束的列資訊 select*frominformation_schema.referential_constraints--獲取外來鍵約束資訊
select*frominformation_schema.check_constraints--獲取檢查約束資訊