概述
在mysql中,null与''是不相同的,''会插入一个空字符串
mysql> select version();
+------------+
| version() |
+------------+
| 5.5.18-log |
+------------+
1 row in set (0.00 sec)
mysql> create table goolen (name varchar(10) primary key);
Query OK, 0 rows affected (0.03 sec)
mysql> insert into goolen values('goolen');
Query OK, 1 row affected (0.00 sec)
mysql> insert into goolen values('');
Query OK, 1 row affected (0.00 sec)
mysql> insert into goolen values(null);
ERROR 1048 (23000): Column 'name' cannot be null
mysql> insert into goolen values('scott');
Query OK, 1 row affected (0.00 sec)
mysql> select * from goolen;
+--------+
| name |
+--------+
| |
| goolen |
| scott |
+--------+
3 rows in set (0.00 sec)
在oracle中,null跟''是一样的,oracle都会理解为是null值;
SQL> select * from v$version where rownum=1;
BANNER
--------------------------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
SQL> create table goolen(name varchar2(10) primary key);
Table created.
SQL> insert into goolen values('goolen');
1 row created.
SQL> insert into goolen values('');
insert into goolen values('')
*
ERROR at line 1:
ORA-01400: cannot insert NULL into ("SYS"."GOOLEN"."NAME")
SQL> insert into goolen values(null);
insert into goolen values(null)
*
ERROR at line 1:
ORA-01400: cannot insert NULL into ("SYS"."GOOLEN"."NAME")
SQL> insert into goolen values('scott');
1 row created.
SQL> select * from goolen;
NAME
------------------------------
goolen
scott
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/23249684/viewspace-1251832/,如需转载,请注明出处,否则将追究法律责任。
最后
以上就是无语钢笔为你收集整理的mysql oracle对空值_注意Oracle与Mysql中的null值的全部内容,希望文章能够帮你解决mysql oracle对空值_注意Oracle与Mysql中的null值所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复