<分区>
Possible Duplicate:
is there a way to avoid calling nextval() if the insert fails in PostgreSQL?
Rails - Postgres does not re-use deleted ids but MySql does?
我有一个非常简单的数据库,PostgreSQL 9.2.1。当我使用此方法插入带有 Doctrine2 的内容时:
$em->persist($entity);
$em->flush();
如果我遇到错误
-means record NOT inserted-
它仍然将 1
添加到我的主键中。因此,如果我刷新页面 50
次,它表示自动增量值设置为 50
。我怎样才能防止这种情况发生?如果记录没有被插入而不是为什么主键增加。这是非常关键的,因为它没有使用索引,而且数量还在不断增加。
我不知道它来自什么以及为什么,所以,我没有尝试任何东西。非常卡在这一点上。