在Oracle中执行完下面的4条SQL语句,最后两条的查询结果不一样,有谁知道是什么原因吗
delete from t_aa;INSERT into T_AA 
select * from v_user t;--v_user 是一个视图select count(*) from T_AA;select count (*) from v_user;

解决方案 »

  1.   

    可见性一致否?select 和insert可能会因为权限的不同有不同的可见性。
      

  2.   

    视图每次打开时,都会反映源表的变动情况,有可能在你执行insert后,视图发生了变化。create table t_test
    (
    id int,
    name varchar2(20)
    )select * from t_testinsert into t_test values (1,'aaa');
    insert into t_test values (2,'bbb');
    insert into t_test values (3,'ccc');select * from v_testcreate view v_test as select * from t_testinsert into t_test1 select id,name from v_testinsert into t_test values (4,'ddd');select count(1) from t_test;
    select count(1) from t_test1;COUNT(1)               
    ---------------------- 
    4                      COUNT(1)               
    ----------------------