insert into A(a1) VALUES ( select b1 from B where id= '1');
这样在pl/sql里提示错误。可以这样实现么?该怎么写?

解决方案 »

  1.   

    insert into a(a1)
    select b1 from B where id= '1'
      

  2.   

    语法错误。insert into test(....) select ...from t;
      

  3.   

    就是 insert into test(id) select id from test2 where id=1;
      

  4.   

    insert into test(....) select ...from t;insert into test(....) values(....);    --这个是sql的写法,不是pl/sql的
      

  5.   

    既然要将查询的结果插入表,则不能带VALUES关键字
    如果你只想填充A1字段,而且不存在违反约束问题的话,你可以根据表A中字段的顺序,来组织
    查询结果中字段的顺序(对应A.A1以外的字段都以NULL代替)。
    例:假设表A共有5个字段,A1是第一个,则
    insert into a select b1 from B where id= '1';
      

  6.   

    不好意思,复制你的代码后,鼠标点得快了些:
    insert into a select b1,null,null,null,null from B where id= '1';