本想实现如下功能
insert into table1 (a,b) values(123,(select id from table2 ))当然,没成功。请教,用存储过程如何实现。最好详细点的代码。

解决方案 »

  1.   

    批量插入也可以指定列啊,不要values关键字SQL> create table t2 as select empno,ename from emp;Table created.SQL> truncate table t2;Table truncated.SQL> insert into t2(empno) select empno from emp;14 rows created.
      

  2.   

    insert into table1 (a,b) select 123, id from table2 
    看看这样行不行
      

  3.   

    你多加了value关键字了,3楼的正解
      

  4.   


    我发现大家对 value values 运用理解的有歧义,不清楚insert into aaa value (select 1 from dual)这样的语句能使用value,但不能使用values 。
      

  5.   


    insert into aaa value (select 1 from dual) --不能指定具体的列,只能全表插入。建议如2楼方法。