该表字段有4个,MACHINE_ID、NAME、ENTRY、STATE。
其中MACHINE_ID为001的数据有17条。
我想插入MACHINE_ID为002,其他字段值与MACHINE_ID为001的数据相同的17条记录,
如何写这个sql? 

解决方案 »

  1.   

    insert into tbl 
    select '002',name,entry,state from table1 where machine_id='001';
      

  2.   

    insert into table select * from table
    不过设计似乎有些问题,数据冗余了
      

  3.   

    使用2楼的做法,出错如下:
    ERROR at line 2:
    ORA-00936: missing expression
      

  4.   

    我写的是insert into ...select ....语法结构,具体写法参照一楼,
      

  5.   

    insert into tbl 
    select '002',name,entry,state from table1 where machine_id='001';