SQL删除外键约束
文章目录
使用如下SQL语句查询出表中外键约束名称:
1 select name
2 from sys.foreign_key_columns f join sys.objects o on f.constraint_object_id=o.object_id
3 where f.parent_object_id=object_id('表名')

执行如下SQL语句删除即可。
1 alter table 表名 drop constraint 外键约束名
使用如下SQL语句查询出表中外键约束名称:
1 select name
2 from sys.foreign_key_columns f join sys.objects o on f.constraint_object_id=o.object_id
3 where f.parent_object_id=object_id('表名')

执行如下SQL语句删除即可。
1 alter table 表名 drop constraint 外键约束名
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册⭐️ Admin快速开发: https://show.cool-admin.com/
赞 0⭐️ 官方文档: https://cool-js.com
赞 0⭐️ chatgpt在线体验: https://cool-js.com/ai/chat-vip/index.html?r=helloworld
赞 0