create database shangji
create table student
(sno char(6) primary key,
sname varchar(10),
sex char(2),
age int,
dept char(10)
);
insert
into student(sno,sname,sex,age,dept)
values('001101','宋大方','男','19','计算机');
insert
into student(sno,sname,sex,age,dept)
values('002102','李王','男','20','信息');
insert
into student(sno,sname,sex,age,dept)
values('991101','张并','男','18','计算机');
insert
into student(sno,sname,sex,age,dept)
values('991102','王雷','女','19','计算机');
insert
into student(sno,sname,sex,age,dept)
values('991103','张建国','男','18','计算机');
insert
into student(sno,sname,sex,age,dept)
values('991104','李平方','男','18','计算机');
insert
into student(sno,sname,sex,age,dept)
values('991201','陈东辉','男','19','计算机');
insert
into student(sno,sname,sex,age,dept)
values('991202','葛鹏','男','21','计算机');
insert
into student(sno,sname,sex,age,dept)
values('991203','潘桃芝','女','19','计算机');
insert
into student(sno,sname,sex,age,dept)
values('991204','姚一峰','男','18','计算机');
insert
into student(sno,sname,sex,age,dept)
values('001102','许辉','女','22','计算机');
insert
into student(sno,sname,sex,age,dept)
values('001201','王一山','男','20','计算机');
insert
into student(sno,sname,sex,age,dept)
values('001202','牛莉','女','19','计算机');
insert
into student(sno,sname,sex,age,dept)
values('002101','牛莉莉','女','19','信息');
select*from student
create table course
(cno char(5) primary key,
cname varchar(20),
ccredit int
);
insert
into course
values('01001','计算机基础','3');
insert
into course
values('01002','程序设计','5');
insert
into course
values('02003','数据结构','6');
insert
into course
values('02002','计算机网络','6');
insert
into course
values('01003','微机原理','8');
insert
into course
values('02004','操作系统','6');
insert
into course
values('03001','软件工程','3');
insert
into course
values('03002','大型数据库','2');
insert
into course
values('03003','图像处理','2');
create table teacher
(tno char(6) primary key,
tname char(10),
sex char(2),
age int,
prof char(10),
sal int,
comm int,
dept varchar(20)
);
insert
into teacher
values('000001','李英','女','39','讲师','1100','1200','计算机');
insert
into teacher
values('000002','张雪','女','57','教授','3000','2000','计算机');
insert
into teacher
values('000003','张朋','男','65','教授','3000','2000','计算机');
insert
into teacher
values('000004','王平','女','43','讲师','1200','1200','计算机');
insert
into teacher
values('000005','李力','男','33','助教','800','500','信息');
insert
into teacher
values('000006','许红霞','女','38','副教授','2000','1500','信息');
insert
into teacher
values('000007','许永军','男','51','教授','3000','1900','信息');
insert
into teacher
values('000008','李桂青','女','30','讲师','1200','1000','计算机');
insert
into teacher
values('000009','王一凡','女','28','讲师','1200','800','信息');
insert
into teacher
values('000010','田峰','男','47','教授','3000','1800','计算机');
create table sc
(sno char(6),
cno char(5),
score smallint,
foreign key(sno)references student(sno),
foreign key(cno)references course(cno)
);
insert
into sc
values('991101','01001','88');
insert
into sc
values('991102','01001','93');
insert
into sc
values('991103','01001','90');
insert
into sc
values('991101','01002','90');
insert
into sc
values('991102','01002','98');
insert
into sc
values('991103','01002','74');
insert
into sc
values('991104','01002','85');
insert
into sc
values('001201','01002','64');
insert
into sc
values('991104','02001','33');
insert
into sc
values('99114','01001','35');
insert
into sc
values('991201','01001','76');
create table tc
(tno char(6),
cno char(5),
foreign key(tno)references teacher(tno),
foreign key(cno)references course(cno)
);
insert
into tc
values('000001','02001');
insert
into tc
values('000008','02002');
insert
into tc
values('000003','02001');
insert
into tc
values('000010','02003');
insert
into tc
values('000001','01001');
insert
into tc
values('000002','01002');
insert
into tc
values('000002','01003');
insert
into tc
values('000004','02002');
insert
into tc
values('000005','01001');
insert
into tc
values('000006','01002');
insert
into tc
values('000003','01003');
这是我写的代码,以下是问题
消息 547,级别 16,状态 0,第 1 行
INSERT 语句与 FOREIGN KEY 约束"FK__tc__cno__060DEAE8"冲突。该冲突发生于数据库"shangji",表"dbo.course", column 'cno'。
语句已终止。
(1 行受影响)
消息 547,级别 16,状态 0,第 7 行
INSERT 语句与 FOREIGN KEY 约束"FK__tc__cno__060DEAE8"冲突。该冲突发生于数据库"shangji",表"dbo.course", column 'cno'。
语句已终止。
(1 行受影响)
(1 行受影响)
(1 行受影响)
(1 行受影响)
(1 行受影响)
(1 行受影响)
(1 行受影响)
(1 行受影响)
我要怎么解决啊?急啊!!!