背景: 使用mysql的可视化工具时,表中有个 id 字段,且某一行的 id 为(null),是因为在 insert 的时候就没有传入数据。后来试图修改 id 字段为 not null,出现如下图的错误: 原因:表中某条数据的 id 为(null),又想修改 id 为 not null,两者冲突啦~ 解决:将(null)的 id 搞一个值,使其符合 not null,然后再修改 id 为 not null 即可。