时间:2021-07-01 10:21:17 帮助过:13人阅读
SQL> select * from test_null where nvl(name_,‘‘)=‘‘;
no rows selected
SQL> select * from test_null where nvl(name_,‘A‘)=‘A‘;
ID_ NAME_
---------- ----------
2
3
SQL>
2.关于以上现象的解释
oracle 将‘‘ 当成了null 处理。每个null都是独一无二的,对null的操作只能是 is null OR is not null,对于null的=<>,>,<的逻辑判断都会得到否。
3.看看null与‘‘在Mysql中的表现
C:\Users\zen>mysql -uzen -p Enter password: **** Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.6.24-log MySQL Community Server (GPL) Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement. mysql> use product_test; Database changed mysql> drop table test_null; Query OK, 0 rows affected (0.37 sec) mysql> create table test_null(id_ int,name_ varchar(127)); Query OK, 0 rows affected (0.59 sec) mysql> insert into test_null values(1,‘oracle‘),(2,‘‘),(3,null); Query OK, 3 rows affected (0.08 sec) Records: 3 Duplicates: 0 Warnings: 0 mysql> select * from test_null; +------+--------+ | id_ | name_ | +------+--------+ | 1 | oracle | | 2 | | | 3 | NULL | +------+--------+ 3 rows in set (0.00 sec) mysql> select * from test_null where name_ is null; +------+-------+ | id_ | name_ | +------+-------+ | 3 | NULL | +------+-------+ 1 row in set (0.06 sec) mysql> select * from test_null where name_=‘‘; +------+-------+ | id_ | name_ | +------+-------+ | 2 | | +------+-------+ 1 row in set (0.00 sec) mysql> select * from test_null where name_<>‘‘; +------+--------+ | id_ | name_ | +------+--------+ | 1 | oracle | +------+--------+ 1 row in set (0.00 sec) mysql> select * from test_null where name_ is not null; +------+--------+ | id_ | name_ | +------+--------+ | 1 | oracle | | 2 | | +------+--------+ 2 rows in set (0.00 sec) mysql>
4.在mysql中null 就是null,‘‘就是空字符,没有将二者混淆起来。
oracle 中的null与''
标签:option 1.2 with sel comm monitor res pass rpo