创建一张表(name非空,age可空)[root@localhost][test]: create table user (name varchar(20) not null ,age int);Query OK, 0 rows affected (0.69 sec)可以插入空字符串[root@localhost][test]: insert into user values('',19);Query OK, 1 row affected (0.05 sec)插入空字符串,null值[root@localhost][test]: insert into user values('',null);Query OK, 1 row affected (0.08 sec)不能插入null值[root@localhost][test]: insert into user values(null,null);ERROR 1048 (23000): Column 'name' cannot be null查看字符串占用空间[root@localhost][test]: select length(name),length(age) from user where age is null;+--------------+-------------+| length(name) | length(age) |+--------------+-------------+| 0 | NULL |+--------------+-------------+1 row in set (0.02 sec)查看字符串长度[root@localhost][test]: select char_length(name),char_length(age) from user where age is null;+-------------------+------------------+| char_length(name) | char_length(age) |+-------------------+------------------+| 0 | NULL |+-------------------+------------------+1 row in set (0.05 sec)判断字符串是否为空,如果为空,则isnull(字段)=1[root@localhost][test]: select isnull(name),isnull(age) from user where age is null;+--------------+-------------+| isnull(name) | isnull(age) |+--------------+-------------+| 0 | 1 |+--------------+-------------+1 row in set (0.00 sec)