ORACLE 在not in中使用null的问题
以前还专门小总结过一下ORACLE中关于NULL的一些问题,碰巧今天在看书的过程中又看到了另外一个以前没发现的需要注意的地方,那就是在not in中使用null的问题。
SQL> select * from dept;
DEPTNO DNAME LOC
---------- -------------- -------------
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
SQL> select deptno
2 from dept
3 where deptno in (10,50,null);
DEPTNO
----------
10
//看到使用in的时候即便有null 也是正常的 下面看一下not in
SQL> select deptno
2 from dept
3 where deptno not in (10,50);
DEPTNO
----------
20
30
40
//这里看起来和我们的预期挺符合的哦
SQL> select deptno
2 from dept
3 where deptno not in (10,50,null);
no rows selected
//怎么回事 为什么加了个null 前面的20、30、40三条数据就不显示出来了
IN和NOT IN本质上都是OR运算,因而计算逻辑OR时处理NULL的方式不同,产生的结果也不同。
下面我们分析一下前面的三条语句
SQL> select deptno
2 from dept
3 where deptno in (10,50,null);
这里可以等价于where deptno=10 or deptno=50 or deptno=null,由于是or相连接,那么只要有一个条件为TRUE,整个就喂TRUE了。所以deptno为10的记录显示出来了。
SQL> select deptno
2 from dept
3 where deptno not in (10,50,null);
这里等价于where not (deptno=10 or deptno=50 or deptno=null),拿deptno=20的记录来举例吧。
not (20=10
相关文档:
原文地址:http://blog.csdn.net/fengyun14/archive/2007/03/25/1540433.aspx
关于Linux 下kernel.shmmax 的设置问题
下面是Oracle 文档上的解释, http://download-west.oracle.com/doc...e.htm#sthref107
SHMMAX Available physical memory Defines the maximum allowable size of one shared memory segment.
The ......
作者:罗代均 http://hi.baidu.com/luodaijun/
使用基于函数的索引(FBI)时,需要先设置初始化参数query_rewrite_enabled=TRUE(默认为false)
该参数在init.ora里设置,以oracle 9i2为例,init.ora文件路径为D:\oracle\admin\mydb\pfile,我这里把oracle装在D盘,mydb是我的数据库.
--顺便说说,创建函数索引的方法
有表emp ......
oracle 用户密码和资源管理
oracle中使用profile对用户密码和资源进行管理。
SQL> select * from dba_profiles order by resource_name;
PROFILE RESOURCE_NAME RESOURCE_TYPE LIMIT
------------------------------ -------------------------------- ------- ......
主要方法是通过使用CASE表达式来“标记”一个值是否为NULL。这里标记有两个值,一个表示NULL,一个表示非NULL。这样,只要在ORDER BY子句中增加标记列,便可以很容易的控制空值是排在前面还是排在后面,而不会被空值所干扰。
SQL> select ename,sal,comm from emp;
ENAME SAL COMM
----- ......