Dust Of Dream

知识真的是一个圆么?

Oracle SQL培训笔记[开发人员][二]

三 null的那些事

  1. 在order 中,简单把null认为是最大
  2. 与null的运算,返回null
    SQL> select 1 + null from dual;

        
    1+NULL
    ----------
  3. 与null的字符串合并,忽略null
    SQL> select 'Hi'||null from dual;

    'HI'||NULL
    ----------
    Hi
  4. Null的查询为is null
  5. Count(field),不包括null
  6. 如果索引条目全为null,则索引不记录null
  7. In/not in与null
  8. Exists/not exists与null
    SQL> select * from t1;

    A          B
    ---------- ----------
    1          1
    2          
    3          

    SQL
    > select * from t2;

    A          B
    ---------- ----------
    1          1
    2          

    SQL
    > select * from t1 where b in (select B from t2);

    A          B
    ---------- ----------
    1          1

    SQL
    > select * from t1 where b not in (select B from t2);

    A          B
    ---------- ----------

    SQL
    > select * from t1 where exists (select * from t2 where t2.b = t1.b);

    A          B
    ---------- ----------
    1          1

    SQL
    > select * from t1 where not exists (select * from t2 where t2.b = t1.b);

    A          B
    ---------- ----------
    3          
    2          

    exists主要用于片面的,有满足一个条件的即可,  所以速度快很多.    in   主要用于具体的集合操作,   有多少满足条件.

posted on 2007-10-01 12:25 Anemone 阅读(924) 评论(0)  编辑  收藏 所属分类: 牧羊阵法


只有注册用户登录后才能发表评论。


网站导航:
 

My Links

Blog Stats

News

常用链接

留言簿(1)

随笔分类

随笔档案

新闻档案

相册

常去网站

搜索

积分与排名

最新评论

阅读排行榜

评论排行榜