修改数据库2

create database StudentInfo
go
use StudentInfo
go
create table CourseInfo
(
CourseNO int not null,
CourseName char(20) not null,
Marks int not null
)
create table StuInfo
(
StuID int not null,
StuName char(10) not null,
StuSex bit not null
)
create table StuExam
(
ExamNO int not null,
StuID int not null,
CourseNO int not null,
Score int not null
)
alter table CourseInfo
add constraint PK_courseNO primary key (CourseNO)
alter table CourseInfo
add constraint DF_marks default (1) for Marks
alter table CourseInfo
add constraint CH_marks check (Marks >=1 and Marks <=5)
alter table StuInfo
add constraint PK_StuID primary key (StuID)
alter table StuInfo
add constraint CH_StuID check (StuID >0 and StuID<=1000)
alter table StuExam
add constraint PK_ExamNO primary key (ExamNO)
alter table StuExam
add constraint FK_StuID foreign key (StuID) references StuInfo (StuID)
alter table StuExam
add constraint FK_CourseNO foreign key (CourseNO) references CourseInfo (CourseNO)
alter table stuExam
add constraint DF_Score default (0) for Score
--修改列(StuSex)把列的类型改为char
alter table StuInfo alter column StuSex char(10)

alter table StuInfo add CallPhone int null

select Score,StuName ,StuSex from StuExam,StuInfo

insert into StuInfo (StuID,StuName,CallPhone) values(,,,)
insert into StuInfo (,,,) values(,,,)
insert into StuInfo () values ()
insert into StuInfo () values ()


update StuInfo set CallPhone=110 where StuSex='男'
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值