Actually TRUNCATE is a DDL, and all DDL does a commit, then the
data dictionary update, then another commit. The point is, if the
TRUNCATE fails, there was an implicit commit that preceded the
attempted TRUNCATE, and commited your transaction that was open up to
that point.
So, if session one does an insert into table test1, and does not
commit, then session two does an insert into table test2, and does
not commit, then each session has an open (uncommitted) transaction.
Now, if session two does a truncate of test1 (which has an uncommited
transaction against it in the session one), the truncate will fail
with an ORA-0054. However, the insert into test2, which was part of
the open transaction of session two, is now committed, even if the
truncate failed.
The point is, DDL does not do a commit in the transaction it is part
of. It does a commit, ending any current transaction in the current
session, then it does a data dictionary update, followed by another
commit.
Partager