LoginSignup
0

posted at

MySQLでデータを一括削除してidを1から振りなおす

やる事

データベースのテーブル内の情報を有無を言わさず全削除。そしてidを1から振り直します。
外部キー制約付いてると一括削除できません。

//一括削除
truncate table テーブル名;
//idを1から振りなおす
ALTER TABLE テーブル名 AUTO_INCREMENT =1;

ていう感じです。

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
What you can do with signing up
0