1 create table `test` ( 2 `cola` varchar(255) not null, 3 `colb` varchar(255) default null 4 ) engine=innodb default charset=utf8;
1 insert into `test`(`cola`, `colb`) values (null, null);
//出现报错,原因是cola是不能插入null值。
1 insert into `test`(`cola`, `colb`) values ('', '');
插入成功,说明字段即使设置为null值的时候,是可以插入空值的
1 select * from `test` where cola is not null
1 select * from `test` where colb is not null
1 select * from `test` where cola <> '';
1 select * from `test` where cola <> '';
1 select count(cola) from `test`;
1 select count(colb) from `test`;
如对本文有疑问, 点击进行留言回复!!
MySQL-关系代数-并、交、差、等值连接、自然连接、左连接。。。
【MySQL牛客】10.获取所有非manager的员工emp_no
网友评论