易截截图软件、单文件、免安装、纯绿色、仅160KB

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


相关文档:

oracle中connect by prior实现递归查询

oracle中connect by prior实现递归查询
收集的几条在oracle中通过connect by prior来实现递归查询
Start with...Connect By子句递归查询一般用于一个表维护树形结构的应用。
创建示例表:
CREATE TABLE TBL_TEST
(
ID    NUMBER,
NAME VARCHAR2(100 BYTE),
PID   NUMBER    ......

Oracle 修改数据文件的路径和名称

Microsoft Windows XP [版本 5.1.2600]
(C) 版权所有 1985-2001 Microsoft Corp.
C:\Documents and Settings\Admin>sqlplus "/ as sysdba"
SQL*Plus: Release 10.2.0.1.0 - Production on Fri Nov 20 19:31:44 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g E ......

ORACLE ORA

对于x$的情况
SQL> grant select on sys.x$bh to t1;
grant select on sys.x$bh to t1
ERROR at line 1:
ORA-02030: can only select from fixed tables/views
对于fixed tables/views只能select
如果想把x$bh的select权限grant给其他用户怎么办呢,可以变通一下
SQL> create view xbh as select * from sys.x$ ......

如何解除Oracle 帐号锁定(the account is locked)

解决办法:
1.使用Oracle用户登录系统,在CMD中启用SQLPLUS
2.sqlplus /nolog
3.SQL> connect /as sysdba
      Connected.
4.SQL> alter user system account unlock;
       User altered.
锁定账号方法:
1.SQL> alter user system account lock;
     & ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号