[create sort_menu] ALTER TABLE `dbr_sort_menu` MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=16; ALTER TABLE your_table_name AUTO_INCREMENT = 0; DELIMITER // CREATE PROCEDURE ResetAutoIncrement() BEGIN DECLARE done INT DEFAULT FALSE; DECLARE tableName VARCHAR(255); DECLARE cur CURSOR FOR SELECT table_name FROM information_schema.tables WHERE table_schema = DATABASE() AND table_type = 'BASE TABLE'; DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; OPEN cur; read_loop: LOOP FETCH cur INTO tableName; IF done THEN LEAVE read_loop; END IF; SET @sql = CONCAT('ALTER TABLE ', tableName, ' AUTO_INCREMENT = 0;'); PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt; END LOOP; CLOSE cur; END // DELIMITER ;