有个问题  一直没想到怎么做
就是 把emp表中的数据按照sale值大小分别插入emp_low, emp_med, emp_high中
如果sale值在1000以下则插入emp_low中
sale值在1000到2000之间插入emp_med中
2000以上插入emp_high中
四个表的结构相同
怎么写呢??

解决方案 »

  1.   

    insert all
        when (sale<1000) then into emp_low
        when (sale>=1000 and sqle<=2000) then into emp_med
        else into emp_high
        select * from emp;
      

  2.   

    必须是oracle 9i或以上的版本。
      

  3.   

    当使用FIRST操作符执行多表插入时,如果数据已经满足了先前条件,并且已经被插入到某表,
    那么该行数据在后续插入中将不会被再次使用。
    INSERT FIRST
    楼住的应该用  INSERT FIRST ,刚才又看了下书中这段
      

  4.   

    可以说的详细点么? INSERT FIRST  是怎么用的?insert all 
        when (sale <1000) then into emp_low 
        when (sale>=1000 and sqle <=2000) then into emp_med 
        else into emp_high 
        select * from emp; 
    这段我看的不是很懂,执行也出问题,可以帮忙解释一下吗?
    谢谢~~~
      

  5.   

    在Oracle操作过程中经常会遇到同时向多个不同的表插入数据,此时用该语句就非常合适。All表示非短路运算,即满足了第一个条件也得向下执行查看是否满足其它条件,
    而First是短路运算找到合适条件就不向下进行。