z-auto-increment-0.sql 880 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. [create sort_menu]
  2. ALTER TABLE `dbr_sort_menu`
  3. MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=16;
  4. ALTER TABLE your_table_name AUTO_INCREMENT = 0;
  5. DELIMITER //
  6. CREATE PROCEDURE ResetAutoIncrement()
  7. BEGIN
  8. DECLARE done INT DEFAULT FALSE;
  9. DECLARE tableName VARCHAR(255);
  10. DECLARE cur CURSOR FOR
  11. SELECT table_name
  12. FROM information_schema.tables
  13. WHERE table_schema = DATABASE() AND table_type = 'BASE TABLE';
  14. DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
  15. OPEN cur;
  16. read_loop: LOOP
  17. FETCH cur INTO tableName;
  18. IF done THEN
  19. LEAVE read_loop;
  20. END IF;
  21. SET @sql = CONCAT('ALTER TABLE ', tableName, ' AUTO_INCREMENT = 0;');
  22. PREPARE stmt FROM @sql;
  23. EXECUTE stmt;
  24. DEALLOCATE PREPARE stmt;
  25. END LOOP;
  26. CLOSE cur;
  27. END //
  28. DELIMITER ;