PHPカンファレンス2016@北海道の資料です http://phpcon.sapporo-php.net/2016/
DBの主キーカラムに自動連番(MySQLならAUTO_INCREMENT、SQL ServerならIDENTITY、OracleやPostgreSQLならシーケンス)を設定していると、基本的には連続した数字が付番されていくのですが、行削除もしていないのに抜け番が発生する場合があります。 INSERTが制約にひっかかって失敗した トランザクションをロールバックした などの場合です。 特にトランザクションのロールバックは、DB全体の変更をなかったことにするはずなのに連番だけは進んだまま戻らないということで、知らないと違和感があるものです。 連番が戻らない理由 PostgreSQLのドキュメントがこう説明しています。 同一のシーケンスから数値を取得する同時実行トランザクション同士のブロックを防止するため、nextval演算は決してロールバックされません。 http://www.postgresq
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く