刚才试了一下
第一次select得到原来数据
然后另一个用户update commit后,
原来用户在一次select得到update后的数据

解决方案 »

  1.   

    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.
      

  2.   

    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
      

  3.   

    oracle中的事务是隐式事务,如果前一个用户没有commit数据,另一个用户则不用看到数据的修改,但如果想进行控制那你可以使用锁,有行级锁select * from ... where ... for update;, 也可以用表级锁 lock table ... in ... mode
      

  4.   

    1.不是这样的,用户一还是用的第一次查询数据,因为 Oracle 要保证每次操作的数据是一致的,如果会自动更新,那在一次的操作中就有两个或者多个时间点的数据了,这是不允许的。Oracle 在用户二提交时,吧所修改的信息写入了 redolog 中,当用户一再一次查询时才会从redolog 中的到用户二的修改信息2.set transaction read only 只是说其它会话的修改结果不论是否提交,都不在当前会话中反应,这样做,就可以使当前会话的一组统计结果是针对某一个时间点的,而不会因为统计的先后,产生数据的不一致性