为什么 SELECT 查询不启动事务? [甲骨文]
Why does not SELECT query start the transaction? [Oracle]
我正在尝试调试下一个 oracle 过程:
create or replace PROCEDURE CASE_6_TRANS_2
AS
V_NUM NUMBER(38,0);
BEGIN
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
SELECT COUNT(AE.ID) INTO V_NUM FROM AUDIT_EVENT AE WHERE ID=10;
COMMIT; --BREAKPOINT
END CASE_6_TRANS_2;
但是当我想在断点处查看当前事务时,V$TRANSACTION table 是空的。
A transaction begins when the first executable SQL statement is encountered. An executable SQL statement is a SQL statement that generates calls to a database instance, including DML and DDL statements and the SET TRANSACTION statement.
根据documentationSELECT查询是DML
- 交易是否开始但未显示在 V$TRANSACTION 中?
- 或者交易根本没有开始。为什么不呢?
事务以 SET TRANSACTION 开始,但是 transaction_id 的分配被延迟到第一个 DML(真正的 DML - 在我的经验中不是 SELECT 语句)
When a transaction begins, Oracle Database assigns the transaction to an available undo data segment to record the undo entries for the new transaction. A transaction ID is not allocated until an undo segment and transaction table slot are allocated, which occurs during the first DML statement.
这对我来说很有意义,没有理由提交或回滚 SELECT。
我正在尝试调试下一个 oracle 过程:
create or replace PROCEDURE CASE_6_TRANS_2
AS
V_NUM NUMBER(38,0);
BEGIN
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
SELECT COUNT(AE.ID) INTO V_NUM FROM AUDIT_EVENT AE WHERE ID=10;
COMMIT; --BREAKPOINT
END CASE_6_TRANS_2;
但是当我想在断点处查看当前事务时,V$TRANSACTION table 是空的。
A transaction begins when the first executable SQL statement is encountered. An executable SQL statement is a SQL statement that generates calls to a database instance, including DML and DDL statements and the SET TRANSACTION statement.
根据documentationSELECT查询是DML
- 交易是否开始但未显示在 V$TRANSACTION 中?
- 或者交易根本没有开始。为什么不呢?
事务以 SET TRANSACTION 开始,但是 transaction_id 的分配被延迟到第一个 DML(真正的 DML - 在我的经验中不是 SELECT 语句)
When a transaction begins, Oracle Database assigns the transaction to an available undo data segment to record the undo entries for the new transaction. A transaction ID is not allocated until an undo segment and transaction table slot are allocated, which occurs during the first DML statement.
这对我来说很有意义,没有理由提交或回滚 SELECT。