将null字段修改为not null先使字段col为空的都填上默认值‘0’: updateyourtablesetcol0wherecolisnull 然
将null字段修改为not null
先使字段col为空的都填上默认值 ‘0’:
update yourtable set col=0 where col is null
然后再col字段上加not null约束:
alter table yourtable modify column_name datatype not null;
