建立学生表
create table Student
(
Sno char(20) primary key,
Sname char(10) not null,
Sage int,
Ssex char(5),
Sdept char(20)
);
建立课程表
create table Course
(
Cno char(10) primary key,
Cname char(20) not null,
Cpno char(10),
Ccredit int,
foreign key(Cpno)references Course(Cno)
);
建立学生选课表
create table SC
(
Sno char(20),
Cno char(10),
Grade numeric(5,2),
foreign key(Sno) references Student(Sno),
foreign key(Cno) references Course(Cno)
);
4. 运行下列语句,为基本表添加数据;
--以下为学生表的初始数据
insert into Student(sname,ssex,sno, sage, sdept) values('李勇','男','200215121',20,'CS');
insert into Student(sname,ssex,sno, sage, sdept) values('刘晨','女','200215122',19,'CS');
insert into Student(sname,ssex,sno, sage, sdept) values('王敏','女','200215123',18,'MA');
insert into Student(sname,ssex,sno, sage, sdept) values('张立','男','200215125',19,'IS');
--
数据库实验一( 表、视图和索引的管理 )
最新推荐文章于 2024-04-26 18:35:50 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)