Sql常用语句
来源:互联网 发布:手机腾讯视频网络错误 编辑:程序博客网 时间:2024/06/07 14:28
SQL SERVER中增加删除约束
---添加主键约束
alter table 表名
add constraint 约束名 primary key (主键)
---添加唯一约束
alter table 表名
add constraint 约束名 unique (字段)
---添加默认约束
alter table 表名
add constraint 约束名 default ('默认内容') for 字段
--添加检查check约束,要求字段只能在1到100之间
alter table 表名
add constraint 约束名 check (字段 between 1 and 100 )
---添加外键约束(主表stuInfo和从表stuMarks建立关系,关联字段为stuNo)
alter table 从表
add constraint 约束名
foreign key(关联字段) references 主表(关联字段)
GO
sql server中删除约束的语句是:
alter table 表名 drop constraint 约束名
sp_helpconstraint 表名 找到数据表中的所有列的约束
例子:
sp_helpconstraint dictionaryType
alter table DictionaryType drop constraint UQ__Dictiona__737584F6060DEAE8
- SQL语句 常用语句
- sql常用sql语句
- SQLite 常用语句 sql语句
- oracle常用SQL语句
- DBA常用SQL语句
- DBA常用SQl语句
- 常用SQL语句
- 常用SQL语句
- oracle常用SQL语句
- oracle常用SQL语句
- 管理常用SQL语句
- 管理常用SQL语句
- 管理常用SQL语句
- 常用SQL语句(Update)
- 常用SQL语句
- SQL常用语句大全
- 常用sql语句1
- 常用Sql语句
- Linux文件系统安全攻略
- 不要让个性化广告吓坏用户
- 常用正则表达式
- 其他几个问题
- js中substring和substr方法区别
- Sql常用语句
- PhoneGap Plugins——NativeControls Plugin的使用与change orientation问题的解决方案
- 嵌入式工程师软硬件道路三步曲
- js日期格式化
- 设计模式(1)
- Perl eval函数探讨
- 利用javascript设置网页快捷键
- C++中的临时变量
- android 之button 屏幕翻转