Sstudent

  学 

   Sno

 姓 

  Sname

  性 

   Ssex

    年 

     Sage

 

   Sdept

  200215121

  200215122

  200215123

  200515125

  李勇

  刘晨

  王敏

  张立

 

 

 

 

  20

  19

  18

  19

    CS

    CS

    MA

    IS

Course

课程号

Cno

  课程名

   Cname

   先行课

  Cpno

   学分

 Ccredit

1

2

3

4

5

6

7

   数据库

   数学

   信息系统

   操作系统

   数据结构

   数据处理

   PASCAL语言

    5

 

    1

    6

    7

 

    6

4

2

4

3

4

2

4

SC

Sno

 课程号

  Cno

  成绩

    Grade

   200215121

   200215121

   200215121

   200215122

   200215122

  1

  2

  3

  2

  3

 92

 85

 88

 90

 80



student 表
create table student
(
sno char() primary key,
sname char() not null,
Ssex char() check( Ssex in('男','女')),
Sage smallint check(Sage between and ),
Sdept char()
) insert into student values('','李勇','男',,'CS')
insert into student values('','刘晨','女',,'CS')
insert into student values('','王敏','女',,'MA')
insert into student values('','张立','男',,'IS') course表
create table course
(
cno char() , --primary key
cname char(),
Cpno char(),
Ccredit smallint,
constraint cPK primary key(cno),
constraint cFK foreign key(Cpno) references course(cno)
) insert into course values('','数据库',null,)
insert into course values('','数学',null,)
insert into course values('','信息系统',null,)
insert into course values('','操作系统',null,)
insert into course values('','数据结构',null,)
insert into course values('','数据处理',null,)
insert into course values('','PASCAL语言',null,)
update course set cpno='' where cno=''
update course set cpno='' where cno=''
update course set cpno='' where cno=''
update course set cpno='' where cno=''
update course set cpno=''where cno=''
select * from course sc 表 完整约束命名子 句----约束名称不能 重复
________________________________________
create table sc
(
sno char() not null,
cno char() not null,
grade smallint check(grade>= and grade<=),
constraint sPK primary key(sno,cno),
constraint sFK foreign key(sno) references student(sno) on delete cascade
on update cascade,
constraint sFK foreign key(cno) references course(cno) on delete no action
on update cascade
) sc 表
create table sc
(
sno char() not null,
cno char() not null,
grade smallint check(grade>= and grade<=),
constraint sPK primary key(sno,cno),
constraint sFK1 foreign key(sno) references student(sno) on delete cascade
on update cascade,
constraint sFK2 foreign key(cno) references course(cno) on delete no action
on update cascade
) sc表.note
________________________________________ create table sc
( sno char(),
cno char(),
grade smallint,
primary key(sno, cno),
foreign key(sno) references student(sno),
foreign key(cno) references course(cno)
)

建表Table-LMLPHP

建表Table-LMLPHP

建表Table-LMLPHP

建表Table-LMLPHP

建表Table-LMLPHP

05-28 11:45