说明
1、该约束条件的意思是在向表中插入数据的时候,有约定条件not null的列值不能为空,否则会报错。
2、not null的字段是不能插入mull的,只能插入空值。
实例
mysql> create table t1(id int not null, name varchar(4)); Query OK, 0 rows affected (0.01 sec) mysql> insert into t1 (id, name) values (1, 'python'); Query OK, 1 row affected, 1 warning (0.00 sec) mysql> insert into t1 (id, name) values (1, null); Query OK, 1 row affected (0.00 sec) mysql> insert into t1 (id, name) values (null, null); ERROR 1048 (23000): Column 'id' cannot be null
以上就是mysql约束条件not null的使用,希望对大家有所帮助。更多mysql学习指路:
推荐操作系统:windows7系统、mysql5.8、DELL G3电脑
Copyright © 2019- net188.cn 版权所有 湘ICP备2022005869号-2
违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务