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]')
SQL语句4
最新推荐文章于 2024-06-09 23:10:45 发布