另外一个可能性是避免使用事务和重置自增计数器,可以结合选择下一个可用id和插入本身;INSERT INTO tablename (id, somefield1, somefield2) SELECT max(id)+1, 'test', 5 FROM tablename