一、建立数据库
本次使用的数据库是SQL server。
建立数据库student,其中包括三个表,学生表S,课程表C,学生表SC。
创建代码如下:
创建学生表
create table S(
SNO char(4) not null primary key,
SNAME char(8) not null,
SEX char(2) not null,
AGE char(2) not null,
SDEPT char(10) not null,
LOGN char(20) not null,
PSWD char(20) not null)
insert into s values('S1','李铭','男','19','计算机软件','1','1')
insert into s values('S2','刘晓鸣','男','20','计算机应用','2','2')
insert into s values('S3','李明','男','22','计算机应用','3','3')
insert into s values('S4','张鹰','女','21','计算机软件','4','4')
insert into s values('S5','刘竞静','女','22','计算机软件','5','5')
insert into s values('S6','刘成刚','男','21','计算机软件','6','6')
insert into s values('S7','王铭','男','22','计算机应用','7','7')
insert into s values('S8','宣明尼','女','18','计算机应用','8','8')
insert into s values('S9','柳红利','女','19','计算机软件','9','9')
创建课程表
create table C(
CNO char(4) not null primary key,
CNAME char(20) not null,
CREDIT integer not null,
CDEPT char(10) not null,
TNAME char(8) not