您的位置:首页 > 数据库

SQL外键约束

2017-08-30 14:44 134 查看

1.查询表已有的外键

select name
from  sys.foreign_key_columns f join sys.objects o on f.constraint_object_id=o.object_id
where f.parent_object_id=object_id('表名')

2.删除表外键

alter table 表名 drop constraint 外键约束名

3.添加外键

alter table 表名 add constraint 外键约束名 foreign key(列名) references 引用外键表(列名)

 

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: