LoginSignup
13
13

More than 5 years have passed since last update.

PostgreSQLでテーブルを空にしてindexも最初から振り直す

Posted at

環境

  • PostgreSQL: 9.4.4

やったこと

何回かtrncateしてデータインポートしてたら、
どんどんIDが大きくなってることに気づいてしまった。

truncateしたらauto incrementのIDも
1から振りなおしてほしい。

ということで、

TRUNCATE TABLE table_name RESTART IDENTITY;

で解決。

RESTART IDENTITYを入れないとだめでした。

13
13
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
13
13