mysql 设置字段是否可以为null

 

//不允许为null
alter table table1 change id id int(10) not null;
//允许为null
alter table table1 change id id int(10) null;

 

//name_new允许为空
insert table1(id,transactor) values(1,"world");

//transactor不允许为null
mysql> insert table1(id) values(1);
ERROR 1364 (HY000): Field 'transactor' doesn't have a default value

 

 

posted @ 2019-08-04 23:21  anobscureretreat  阅读(8451)  评论(0编辑  收藏  举报