六大约束
1.主键约束(唯一约束 + 非空约束) primary key
2.外键约束 foreign key(字段) references 主表名(字段)
3.唯一约束(允许一行数据为空) unique
4.默认值约束 default
5.检查约束 check
6.非空约束 not null
--新建 学生表
create table student(
stuid int not null,
stuname varchar(100) not null,
stuage int not null,
stusex varchar(10) not null,
stutel varchar(13) not null,
stuaddress varchar(100)
)
--删除 学生表
drop table student
--添加非空约束
alter table student
add constraint NN_labExam check(stuaddress is not null)
--添加 主键约束
alter table student
add constraint PK_p primary key(stuid)
--添加 唯一约束
alter table student
add constraint UN_u unique(stuname)
--插入数据
insert into student values(1,'uu',1,'女','123412314','长沙')
insert into student values(2,'uiu',13,'男','1273412314','长沙')
insert into stu