我正在学习SQL,测试准备问题有一个像这样的用户会话:
CREATE TABLE product (pcode NUMBER(2), pname VARCHAR2(10) );
INSERT INTO product VALUES (1, 'pen');
INSERT INTO product VALUES (2, 'pencil');
SAVEPOINT a;
UPDATE product SET pcode = 10 WHERE pcode = 1;
SAVEPOINT b;
DELETE FROM product WHERE pcode = 2;
COMMIT;
SQL> DELETE FROM product WHERE pcode = 10;
在上面之后我们运行这个命令:
ROLLBACK TO SAVEPOINT a
根据测试指南,这会产生错误;也 - 没有回滚SQL语句。
为什么会这样?
答案 0 :(得分:1)
由于您正在运行commit
命令,因此您的早期savepoint
被删除,而您无法回滚到保存点。
尝试删除提交并重新运行脚本。