1、可以用锁,锁定了该表则别的用户不好做更新操作。 2、 Read-only transactions are useful for running multiple queries against one or more tables while other users update the same tables. During a read-only transaction, all queries refer to the same snapshot of the database, providing a multi-table, multi-query, read-consistent view. Other users can continue to query or update data as usual. A commit or rollback ends the transaction. In the example below, as a store manager, you use a read-only transaction to gather sales figures for the day, the past week, and the past month. The figures are unaffected by other users updating the database during the transaction. DECLARE daily_sales REAL; weekly_sales REAL; monthly_sales REAL; BEGIN ... COMMIT; -- ends previous transaction SET TRANSACTION READ ONLY; SELECT SUM(amt) INTO daily_sales FROM sales WHERE dte = SYSDATE; SELECT SUM(amt) INTO weekly_sales FROM sales WHERE dte > SYSDATE - 7; SELECT SUM(amt) INTO monthly_sales FROM sales WHERE dte > SYSDATE - 30; COMMIT; -- ends read-only transaction ... END; The SET TRANSACTION statement must be the first SQL statement in a read-only transaction and can only appear once in a transaction. If you set a transaction to READ ONLY, subsequent queries see only changes committed before the transaction began. The use of READ ONLY does not affect other users or transactions.
1.你可以用select * from a where ...for update 产生一个Row Share 销定, 这样别的用户就不会更到你 select 的数据. 不知你的目的是作什么用??2.使用Set transaction语句可以打开事务级一致性或者语句级一致性. Set transaction isolation level serializable;事务级一致性 set transaction isolation level committed ;语句级一致性 set transaciton read only;是指事务级一致性是只读的.
在一个只读事务中不得用企图更改数据的语句,否则会引起异常. 只读事务只能使用以下语句: .select( 不包括for update语句) .lock table .set role .alter system .alter session
oracle中的事务是隐式事务,如果前一个用户没有commit数据,另一个用户则不用看到数据的修改,但如果想进行控制那你可以使用锁,有行级锁select * from ... where ... for update;, 也可以用表级锁 lock table ... in ... mode
2、
Read-only transactions are useful for running multiple
queries against one or more tables while other users update the same tables.
During a read-only transaction, all queries refer to the same snapshot of the
database, providing a multi-table, multi-query, read-consistent view. Other users
can continue to query or update data as usual. A commit or rollback ends the
transaction. In the example below, as a store manager, you use a read-only
transaction to gather sales figures for the day, the past week, and the past month.
The figures are unaffected by other users updating the database during the
transaction.
DECLARE
daily_sales REAL;
weekly_sales REAL;
monthly_sales REAL;
BEGIN
...
COMMIT; -- ends previous transaction
SET TRANSACTION READ ONLY;
SELECT SUM(amt) INTO daily_sales FROM sales
WHERE dte = SYSDATE;
SELECT SUM(amt) INTO weekly_sales FROM sales
WHERE dte > SYSDATE - 7;
SELECT SUM(amt) INTO monthly_sales FROM sales
WHERE dte > SYSDATE - 30;
COMMIT; -- ends read-only transaction
...
END;
The SET TRANSACTION statement must be the first SQL statement in a read-only
transaction and can only appear once in a transaction. If you set a transaction to
READ ONLY, subsequent queries see only changes committed before the transaction
began. The use of READ ONLY does not affect other users or transactions.
这样别的用户就不会更到你 select 的数据.
不知你的目的是作什么用??2.使用Set transaction语句可以打开事务级一致性或者语句级一致性.
Set transaction isolation level serializable;事务级一致性
set transaction isolation level committed ;语句级一致性
set transaciton read only;是指事务级一致性是只读的.
在一个只读事务中不得用企图更改数据的语句,否则会引起异常.
只读事务只能使用以下语句:
.select( 不包括for update语句)
.lock table
.set role
.alter system
.alter session