insert into mytable
 select a.id,a.x1,b.x2,c.x3 from a,b,c where a.id=b.id(+) and a.id = c.id(+);

解决方案 »

  1.   

    楼上的方法不行的,如果C表无id=001的纪录是不会生成mytable中的001,test,xxxxx,null的.
    我一开始就是这样做的!
      

  2.   

    SQL> select * from a2;BBB        CCC
    ---------- --------------------
    103        kaifazhe
    105        kaifazhe
    107        kaifazhe
    开发者     kaifazhe
    101        kaifazheSQL> select * from a4;BBB        CCC
    ---------- --------------------
    22         bb
    11         aa
    33         cc
    开         kai
    发         fa
    者         zhe
    105        aaa
    101        kaifazhe已选择8行。SQL> create table a6 (bbb varchar2(10),ccc1  varchar2(10),ccc2 varchar2(10));表已创建。SQL> insert into a6 select a2.bbb,a2.ccc,a4.ccc from a2,a4 where a2.bbb=a4.bbb(+);已创建5行。SQL> select * from a6;BBB        CCC1       CCC2
    ---------- ---------- ----------
    101        kaifazhe   kaifazhe
    103        kaifazhe
    105        kaifazhe   aaa
    107        kaifazhe
    开发者     kaifazhe我试着可以啊
      

  3.   

    没有问题呀:
    SQL> select * from a;ID     X1
    ------ --------------------
    001    test
    002    test1Elapsed: 00:00:00.00
    SQL> select * from b;ID     X2
    ------ --------------------
    001    *****
    002    aaaElapsed: 00:00:00.10
    SQL> select * from c;ID     X3
    ------ --------------------
    002    ****Elapsed: 00:00:00.10SQL> select a.id as id,a.x1 as x1,b.x2 as x2,c.x3 as x3 from a,b,c where a.id=b.
    id(+) and a.id=c.id(+);ID     X1                   X2                   X3
    ------ -------------------- -------------------- --------------------
    001    test                 *****
    002    test1                aaa                  ****Elapsed: 00:00:00.30SQL> delete from c ;1 row deleted.Elapsed: 00:00:00.20
    SQL> commit;Commit complete.Elapsed: 00:00:00.30
    SQL> select a.id as id,a.x1 as x1,b.x2 as x2,c.x3 as x3 from a,b,c where a.id=b.
    id(+) and a.id=c.id(+);ID     X1                   X2                   X3
    ------ -------------------- -------------------- --------------------
    001    test                 *****
    002    test1                aaaElapsed: 00:00:00.40