如何使用联接从h2数据库的2个表中删除行?

时间:2019-06-24 19:51:44

标签: java database join h2 sql-delete

表测验 quiz_id(FK,PK) 标题

表格问题 quiz_id(FK) QuestionID(PK) 文本 困难

如何在Java中删除具有相同quiz_id的测验和问题?

我试图将2个查询用分号隔开,这是行不通的。

SET REFERENTIAL_INTEGRITY FALSE;
BEGIN TRANSACTION;
DELETE FROM quiz WHERE quiz_id IN (SELECT quiz_id FROM question WHERE 
quiz_id= 2);
DELETE FROM question WHERE quiz_id= 2;
COMMIT;
SET REFERENTIAL_INTEGRITY TRUE;

0 个答案:

没有答案