0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PostgreSQLでオートインクリメントの初期値を変更する

Posted at

概要

システム移行後にデータ登録した際にエラーを吐いたので原因を調べてみたら、idの衝突を起こしていた。
解決方法としてはシーケンスの位置を調整してあげればよい。

バージョン等

PostgreSQL:11.x

解決方法

下記SQLを実行する

-- 名前は各テーブルのシーケンス名に変更してください
SELECT setval('users_id_seq', 50000)
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?