想更新status =60 的前5条记录:
update (select num2 ,status,rownum rn from xgs_register  where  status = 60 and rownum<5)
   set num2 = trunc(dbms_random.value(0, 299)) 
update (select num2 ,status,rownum rn from xgs_register  )
   set num2 = trunc(dbms_random.value(0, 299))
 where status = 60 and rn<5 上面二种方法,都报    此视图的数据操作非法的错误哪道是因为没有主键原因的吗
  该怎么改

解决方案 »

  1.   

    update t
    set x=xxx
    where status = 60 and rownum<5
    行不行
      

  2.   

    update xgs_register set num2 = trunc(dbms_random.value(0, 299)) where status = 60 and rownum<5
      

  3.   

    update xgs_register set num2 = trunc(dbms_random.value(0, 299)) where status = 60 and rownum<=5
      

  4.   

    --2楼正解!
    update xgs_register 
       set num2= trunc(dbms_random.value(0, 299))
     where status=60 and rownum<5;
      

  5.   

    --2楼正解!加个等于
    update xgs_register 
       set num2= trunc(dbms_random.value(0, 299))
     where status=60 and rownum<=5;
      

  6.   

    这是我用自己的表更新的
     update student
     set sdept='MA'
     where rowid in
    (select rd from
     (select rowid rd,rownum rn from student)
     where rn>=1 and rn<=5);
      

  7.   

    select num2 ,status,rownum rn from xgs_register  where  status = 60 and rownum<5
    这句不对,它是返回前5条记录中的status = 60 的记录,不是返回所有status=60记录中的前5条
      

  8.   

    select num2 ,status,rownum rn from xgs_register  where  status = 60 and rownum <5 
    顶8楼!