1
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 1 year has passed since last update.

【備忘録】PostgreSQLでidを初期化(auto_increment)

Posted at

Postgresのidを1に戻す

PostgreSQLでidを初期化する方法です。idを1に戻したい場合に利用してください。

実行コマンドの雛形
ALTER SEQUENCE <table name>_<column name>_seq RESTART WITH <reset id>;
実行コマンドの実例(usersテーブルのidを1に戻す)
ALTER SEQUENCE users_id_seq RESTART WITH 1;
1
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
1
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?