删除时出错:sql错误:ora-00933:sql命令未正确结束

gfttwv5a  于 2021-08-09  发布在  Java
关注(0)|答案(1)|浏览(393)

我正试图使用下面的查询从数据库中删除一个学生记录。但我面对这个错误。

DELETE student, enrolment FROM student INNER JOIN enrolment
WHERE student.stu_nbr=enrolment.stu_nbr and student.stu_nbr = 154;

错误报告-sql错误:ora-00933:sql命令未正确结束00933。00000-“sql命令未正确结束”

4dc9hkyq

4dc9hkyq1#

尝试删除存在注册的学生记录。

delete from student s
where stu_nbr = 154
  and exists (
    select 1
    from enrollment
    where stu_nbr = s.stu_nbr
  );

如果您想从学生表和报名表中删除学生记录,请运行2个查询:

delete from enrollment where stu_nbr = 154;
delete from student where stu_nbr = 154;

如果您想在删除学生时自动删除注册记录,您可能需要查看触发器。

相关问题