--创建学生表并创建约束
create table Student
(
StuNo int identity(1,1) primary key(StuNo), --identity:自增列primary Key:主键约束
StuName nvarchar(20) unique(StuName), --unique:唯一约束
Birthday datetime check(Birthday>GetDate()), --check:检查约束
Address nvarchar(20)
)
--默认约束
alter table Student
add constraint df_Address default ('不确定') for Address --default for:默认约束
--外键约束
Alter table Result
Add constraint fk_StuNo foreign key(StuNo) reference Student(StuNo)
--foreign key reference: 外键约束