[sql]代码库
create database st_db
go
use st_db
go
create table s(
sno char(10) primary key,
sname char(8),
ssex char(2) check(ssex in('男','女')),
sage int check(sage>=17 and sage<=40),
sdept char(2))
go
create table c(
cno char(10) primary key,
cname char(20),
cpno char(10),
ccredit float,
--foreign key(cpno) references c(cno)
)
go
create table sc(
sno char(10),
cno char(10),
grade int,
primary key(sno,cno),
foreign key(sno) references s(sno),
foreign key(cno) references c(cno))
go
insert into s
values('2016117101','李勇','男',20,'CS');
go
insert into s
values('2016117102','刘晨','女',19,'IS');
go
insert into s
values('2016117103','王敏','女',18,'CS');
go
insert into s
values('2016117104','张立','男',17,'CS');
go
insert into c
values('1','数据库','5',4);
go
insert into c
values('2','数学',null,2);
go
insert into c
values('3','信息系统','1',4);
go
insert into c
values('4','操作系统','6',3);
go
insert into c
values('5','数据结构','7',4);
go
insert into c
values('6','数据处理',null,2);
go
insert into c
values('7','Java语言','6',4);
go
insert into sc
values('2016117101','1',92);
go
insert into sc
values('2016117101','2',85);
go
insert into sc
values('2016117101','3',88);
go
insert into sc
values('2016117102','2',90);
go
insert into sc
values('2016117102','3',80);
go
by: 发表于:2018-05-31 11:00:22 顶(1) | 踩(0) 回复
??
回复评论