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

Oracle左右全连接总结

--建立测试数据
create table a(id number);
create table b(id number);
insert into a values(1);
insert into a values(2);
insert into a values(3);
insert into b values(1);
insert into b values(2);
insert into b values(4);
commit;
--左:
--主流数据库通用的方法
select * from a left join b on a.id=b.id;
--Oracle特有的方法
select * from a, b where a.id=b.id(+);
ID ID
---------- ----------
1 1
2 2
3
--右:
--主流数据库通用的方法
select * from a right join b on a.id=b.id;
--Oracle特有的方法
select * from a, b where a.id(+)=b.id;
ID ID
---------- ----------
1 1
2 2
4
--内
--主流数据库通用的方法
select * from a join b on a.id=b.id;
--where关联
select * from a, b where a.id=b.id;
ID ID
---------- ----------
1 1
2 2
--全外
--主流数据库通用的方法
select * from a full join b on a.id=b.id;
--Oracle特有的方法
select *
from a, b
where a.id = b.id(+)
union
select *
from a, b
where a.id(+) = b.id;
ID ID
---------- ----------
1 1
2 2
3
4
--完全,也叫交叉连接或者笛卡尔积
--主流数据库通用的方法
select * from a,b;
--或者
select * from a cross join b;
ID ID
---------- ----------
1 1
1 2
1 4
2 1
2 2
2 4
3 1
3 2
3 4
连接无非是这几个
--内连接和where相同
inner join
--左向外连接,返回左边表所有符合条件的
left join
--右向外连接,返回右边表所有符合条件的
right join
--完整外部连接,左向外连接和右向外连接的合集
full join
--交叉连接,也称笛卡儿积。返回左表中的每一行与右表中所有行的组合
cross join
--补充:
--左向外连接,返回左边表所有符合条件的,
--注意这里没有第二个加号,会直接过滤掉数据,只显示符合条件的记录
select *
from a, b
where a.id = b.id(+)
and b.id = 2;
ID ID
---------- ----------
2 2
--左向外连接,返回左边表所有符合条件的
--注意where上第二个加号,它的作用是修改右边表记录的显示,例如如果b.id(+) = 2,显示为2,否则显示null
select *
from a, b
where a.id = b.id(+)
and b.id(+) = 2;
ID ID
---------- --


相关文档:

oracle数据字典小结


下面按类别列出一些ORACLE用户常用数据字典的查询使用方法。
   
    一、用户
    查看当前用户的缺省表空间
    SQL>select username,default_tablespace from user_users;
    查看当前用户的角色
    SQL ......

Oracle笔记 物化视图

http://www.wangchao.net.cn/bbsdetail_1776477.html
 第 13 章 物化视图
  8.1.5企业版/个人版开始支持
  需要权限:GRANT CREATE MATERIALIZED VIEW,还必须直接赋予GRANT QUERY REWRITE.为实现查询重写,必须使用CBO.
   
   
   
   
   
   
   
  ......

Oracle Lock

http://download-uk.oracle.com/docs/cd/B10501_01/server.920/a96524/c21cnsis.htm#2937
Types of Locks
Oracle automatically uses different types of locks to control concurrent access to data and to prevent destructive interaction between users. Oracle automatically locks a resource on behalf of a tran ......

只读权限oracle用户

-- Create the user
create user SMCQUERY
  identified by SMCQUERY;
-- Grant/Revoke role privileges
grant connect to SMCQUERY;
-- Grant/Revoke system privileges
grant select any table to SMCQUERY;
grant debug any procedure to SMCQUERY;
grant debug connect session to SMCQUERY;
grant cr ......

oracle 约束(constraint)的几个参数的小研究

首先搞清下几个概念:
ORACLE中,约束分deferred 跟 immediate 2种:
  deferred:如果 Oracle 在事务提交(commit)时才对约束执行检查,则称此约束是延迟的(deferred)。如果数据违反了延迟约束,提交操作将导致事务被回滚(undo)。
  immediate:如果约束是即时的(immediate)(非延迟的),则此约束将在 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号