ORACLE外连接小结~
好几次想用到外连接的时候都忘了具体的用法是怎样的,比如说(+)该加在等号的哪一端,或者LFET OUTER JOIN该用在整条语句中的哪个部分。今天正好又碰到一个相关的问题,借此机会总结一下,以后也方便查询,不用每次都去百度了。
//table1和table2为两个测试表 随便插入几条数据
SQL> select * from table1;
ID NAME
---------- --------------------
1 wh
2 wp
3 wq
SQL> select * from table2;
ID NAME
---------- --------------------
4 wr
1 wh
//正常查询
SQL> select a.name,b.name
2 from table1 a,table2 b
3 where a.id=b.id;
NAME NAME
-------------------- --------------------
wh wh
//显示出table1中的所有记录 table2中无相应记录则置NULL
SQL> select a.name,b.name
2 from table1 a,table2 b
3 where a.id=b.id(+);
NAME NAME
-------------------- --------------------
wh wh
wq
wp
//显示出table2中的所有记录 table1中无相应记录则置NULL
SQL> select a.name,b.name
2 from table1 a,table2 b
3 where a.id(+)=b.id;
NAME NAME
-------------------- --------------------
wh wh
wr
//呵呵,这里本想尝试一下全外连接,不过使用(+)好像不行
SQL> select a.name,b.name
2 from table1 a,table2 b
3 where a.id(+)=b.id(+);
where a.id(+)=b.id(+)
*
ERROR at line 3:
ORA-01468: a predicate may reference only one outer-joined table
//左外连接
SQL> select a.name,b.name
2 from table1 a
3 left outer join table2 b
4 on a.id=b.id;
NAME NAME
-------------------- --------------------
wh wh
wq
wp
//右外连接
SQL> select a.name,b.name
2 from table1 a
3 right outer join table2 b
4 on a.id=b.id;
NAME NAME
-------------------- --------------------
wh wh
wr
//右外连接
SQL> select a.name,b.name
2 from table2 b
3 right outer join table1 a
相关文档:
1.启动TNS监听
C:\Documents and Settings\Administrator>lsnrctl start
LSNRCTL for 32-bit Windows: Version 10.2.0.1.0 - Production on 13-7月 -2008 12:0
3:55
Copyright (c) 1991, 2005, Oracle. All rights reserved.
启动tnslsnr: 请稍候...
TNSLSNR for 32-bit Windows: Version 10.2.0.1.0 - Pr ......
Oracle数据字典常用查询
--查看当前用户所有表及描述
select o.object_name,c.comments
from user_objects o
left outer join user_tab_comments c
on o.object_name=c.table_name
where object_type='TABLE'
and c.comments like '%项目%'
--查看当前用户所有字段信息及描述
select c.table ......
向Oracle数据库表中插入十几万条数据,可是当插入3万多条后,程序就抛
Java代码
ORA-01000 maximum open cursors exceeded
ORA-01000 maximum open cursors exceeded
异常信息。Google了异常信息,得知这样的错误很容易出现在Java代码中的主要原因是:Java代码在执行conn.crea ......
Oracle最新认证题库资料下载
Actualtests Oracle 1Z0-200 V11.07.08
Actualtests Oracle 1Z0-211 V11.10.08
Actualtests Oracle 1Z0-212 V11.07.08
Actualtests Oracle 1Z0-213 V11.07.08
Actualtests Oracle 1Z0-101 V11.07.08
Actualtests Oracle 1Z0-132 V11.07.08
Actualtests Oracle 1Z0-140 V11.21.08
Actual ......