create table student
(
sid char(10) primary key, //学号
status char(6), //状态
check(status in ('in','out')),//在籍,开除
);create table score
(
sid char(10),//学号
eid varchar(5), //eid为考试ID号,应该用不到
grade number(4,1),//成绩
primary key (sid,eid),
foreign key (sid) references student (sid),
foreign key (eid) references exam (eid),
);删除所有学生的状态为开除的学生表和成绩表数据。用SQL
(
sid char(10) primary key, //学号
status char(6), //状态
check(status in ('in','out')),//在籍,开除
);create table score
(
sid char(10),//学号
eid varchar(5), //eid为考试ID号,应该用不到
grade number(4,1),//成绩
primary key (sid,eid),
foreign key (sid) references student (sid),
foreign key (eid) references exam (eid),
);删除所有学生的状态为开除的学生表和成绩表数据。用SQL
DELETE FROM score A
WHERE EXISTS (SELECT 1 FROM student WHERE sid = A.sid AND status = 'out')2, 再删除学生表
DELETE FROM student WHERE status = 'out'
我也发一个:delete score
from score a ,student b
where a.sid=b.sid and b.status='out'delete student
where status='out'