暗黙のセーブポイントを使用してデータベースへの変更をロールバックできますか?私はJavaコードを変更して(INSERTs
)、元に戻したいと思っていました。暗黙のセーブポイントを使用してデータベースをロールバックする? - Oracle
0
A
答えて
3
How to COMMIT, ROLLBACK Oracle Transactionsで概要を説明したSAVEPOINTを使用できます。ここで
はそれからSAVEPOINTスニペットです...
SAVEPOINT
Specify a point in a transaction to which later you can roll back.
Example
insert into emp (empno,ename,sal) values (109,’Sami’,3000);
savepoint a;
insert into dept values (10,’Sales’,’Hyd’);
savepoint b;
insert into salgrade values (‘III’,9000,12000);
Now if you give
rollback to a;
Then row from salgrade table and dept will be roll backed. Now you can commit the row inserted into emp table or rollback the transaction.
If you give
rollback to b;
Then row inserted into salgrade table will be roll backed. Now you can commit the row inserted into dept table and emp table or rollback to savepoint a or completely roll backed the transaction.
If you give
rollback;
Then the whole transactions is roll backed.
If you give
commit;
Then the whole transaction is committed and all savepoints are removed.
3
はUsing Oracle Flashback Technologyを見てください。データベースがすでに設定されている場合、挿入前の時間にフラッシュバックすることができます。他のユーザーもこの表を更新している場合は注意してください。また、誤って手動でフラッシュバックすると、自動的にこれを行うコードには組み込みません。
変更は既に行われており、セーブポイントを使用していませんでした。したがって、もし私がJavaコードを使って変更を加えたものを使用できるのであれば、私の質問です。 –
@ darkie15 - 挿入を実行したJavaブロックが完了しても、変数を保持しているメモリオブジェクトがないため、それらを取得する方法がありません。だから、あなたのJavaアプリケーションでは、埋め込みを行ったオブジェクトがおそらくすでに消滅しているので、何が行われたのですか? –