mysql primary key reset

Поделиться
HTML-код
  • Опубликовано: 21 дек 2024
  • Reset mysql primary key. sometimes it may required to reset the value
    here is simple query
    //first delete the primary key
    ALTER TABLE Table_Name DROP ID;
    //then set increment to 1
    ALTER TABLE Table_Name AUTO_INCREMENT = 1;
    //recreate the Id column
    ALTER TABLE Table_Name ADD ID int UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST;

Комментарии •