把原来可空的列变成主键 alter table tableName column columnName int not null; alter table tableName add primary key(columnName); 这样就OK了