SQL语句删除和添加外键、主键的方法
时间:2023-04-16 22:18:35
--删除外键
语法:alter table 表名 drop constraint 外键约束名
如:
alter table Stu_PkFk_Sc drop constraint FK_s
alter table Stu_PkFk_SC drop constraint FK_c
--添加外键
语法:alter table 表名 add constraint 外键约束名 foreign key(列名) references 引用外键表(列名)
如:
alter table Stu_PkFk_Sc
add constraint Fk_s
foreign key (sno)
references Stu_PkFk_S(sno)
go
--删除主键
语法:alter table 表名 drop constraint 主键约束名
如:
alter table Stu_PkFk_S drop constraint PK_S
go
--增加主键
语法:alter 表名 add constraint 主键约束名 primary key(列名)
alter table Stu_PkFk_S add constraint PK_S primary key (sno)
go
标签:删除外键,添加外键
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Java实现AES算法的实例代码
2021-09-25 15:05:52
如何解决Spring in action @valid验证不生效的问题
2023-08-29 07:59:56
flutter实现倒计时加载页面
2023-08-18 23:30:09
![](https://img.aspxhome.com/file/2023/1/109171_0s.gif)
SpringBoot中配置Web静态资源路径的方法
2023-10-26 03:49:21
![](https://img.aspxhome.com/file/2023/4/72564_0s.png)
使用JPA双向多对多关联关系@ManyToMany
2021-12-04 03:37:12
![](https://img.aspxhome.com/file/2023/8/129118_0s.png)
C#实体类转换的两种方式小结
2023-08-01 21:06:45
Java实现抠图片文字或签名的完整代码
2023-04-18 00:04:44
Java的System.getProperty()方法获取大全
2023-11-10 20:12:12
java 算法之快速排序实现代码
2023-01-30 01:44:59
C#学习笔记- 浅谈数组复制,排序,取段,元组
2021-10-21 00:50:58
Android SwipeRefreshLayout超详细讲解
2023-08-22 13:43:28
![](https://img.aspxhome.com/file/2023/7/94257_0s.gif)
IOS 实现摇一摇的操作
2023-07-02 13:46:53
浅谈java常量池
2023-11-18 09:43:50
Java使用Preference类保存上一次记录的方法
2023-05-08 01:49:14
基于java math API 的详细解释说明
2021-10-04 06:51:44
详解SpringBoot和SpringBatch 使用
2023-08-17 19:00:38
Java实现超大Excel文件解析(XSSF,SXSSF,easyExcel)
2023-11-27 11:02:17
![](https://img.aspxhome.com/file/2023/3/60113_0s.png)
Jenkins+Git+Maven自动化部署配置详解
2022-05-20 22:24:43
![](https://img.aspxhome.com/file/2023/4/106194_0s.jpg)
Android中实现长按修改ListView对象的内容
2022-04-13 15:09:08
Android设计模式系列之工厂方法模式
2023-08-16 19:10:17
![](https://img.aspxhome.com/file/2023/8/94978_0s.jpg)