Chinaunix首页 | 论坛 | 博客
  • 博客访问: 103703920
  • 博文数量: 19283
  • 博客积分: 9968
  • 博客等级: 上将
  • 技术积分: 196062
  • 用 户 组: 普通用户
  • 注册时间: 2007-02-07 14:28
文章分类

全部博文(19283)

文章存档

2011年(1)

2009年(125)

2008年(19094)

2007年(63)

分类: Oracle

2008-05-21 22:34:21

 来源:

rem 一半情况下的
SQL> select INFO.SID, INFO.AGE, INFO.NAME, WORK.COMPANY, WORK.ADDRESS
  2  from TEST_INFO INFO , TEST_WORK WORK
  3  where INFO.SID = WORK.SID;

       SID        AGE NAME         COMPANY         ADDRESS                     
---------- ---------- ------------ --------------- ---------------             
      1001         28 Jack         MS              US                          
      1002         33 Micky        Oracle          CHINA                       
      1003         43 Kent         HP              US                          

rem 右连接
SQL> select INFO.SID, INFO.AGE, INFO.NAME, WORK.COMPANY, WORK.ADDRESS
  2  from TEST_INFO INFO right outer join TEST_WORK WORK
  3  on INFO.SID = WORK.SID;

       SID        AGE NAME         COMPANY         ADDRESS                     
---------- ---------- ------------ --------------- ---------------             
      1001         28 Jack         MS              US                          
      1002         33 Micky        Oracle          CHINA                       
      1003         43 Kent         HP              US                          
                                   CANON           JAP                         
                                   SONY            JAP                         
                                   Lenovo          CHINA                       
                                   Apple           US                          

rem 左连接
SQL> select INFO.SID, INFO.AGE, INFO.NAME, WORK.COMPANY, WORK.ADDRESS
  2  from TEST_INFO INFO left outer join TEST_WORK WORK
  3  on INFO.SID = WORK.SID;

       SID        AGE NAME         COMPANY         ADDRESS                     
---------- ---------- ------------ --------------- ---------------             
      1001         28 Jack         MS              US                          
      1002         33 Micky        Oracle          CHINA                       
      1003         43 Kent         HP              US                          
      1004         32 Hence                                                    

rem 全连接
SQL> select INFO.SID, INFO.AGE, INFO.NAME, WORK.COMPANY, WORK.ADDRESS
  2  from TEST_INFO INFO full outer join TEST_WORK WORK
  3  on INFO.SID = WORK.SID;

       SID        AGE NAME         COMPANY         ADDRESS                     
---------- ---------- ------------ --------------- ---------------             
      1001         28 Jack         MS              US                          
      1002         33 Micky        Oracle          CHINA                       
      1003         43 Kent         HP              US                          
      1004         32 Hence                                                    
                                   CANON           JAP                         
                                   SONY            JAP                         
                                   Lenovo          CHINA                       
                                   Apple           US                          

已选择8行。

SQL> spool off

阅读(574) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~