SQL语句4

use student
select *from student
--删除表
drop table student
--建表
create table student
(
id int,
age int,
score int,
addr nvarchar(20)
)
--创建check约束
ALTER table student add constraint aa check (score between 0 and 100)
--删除check约束
ALTER table student drop constraint aa
ALTER table student add constraint qq check(age between 0 and 150)
ALTER table student drop constraint qq
--创建unique约束、
ALTER table student add constraint 序号 unique(id)
ALTER table student drop constraint 序号
--禁止约束
ALTER table student nocheck constraint 序号
--解禁约束
ALTER table student check constraint 序号
--建立主键
ALTER table student add constraint 主键 primary key(id)
--删除主键约束
ALTER table student drop constraint 主键
--8位数约束第一个0,第二个0,第三个_,第四个0-9,……
ALTER table student add constraint 地址 
check(addr like'[0][0][_][0-9][0-9][a-z][a-z][a-z]')



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值