您好,欢迎访问一九零五行业门户网

修复mysql数据库自增字段的AUTO_INCREMENT起始值的存储过程_MySQL

delimiter $$create procedure repair_auto_increment(in db varchar(10)) begin declare tmp_name char(30) default ; declare tmp_cursor cursor for select table_name from information_schema.tables where table_schema=db; declare continue handler for sqlstate '02000' set tmp_name = null; open tmp_cursor; fetch tmp_cursor into tmp_name; while(tmp_name is not null) do set @sql = concat('alter table ', tmp_name); set @sql = concat(@sql, ' auto_increment=1'); prepare stmt from @sql; execute stmt; fetch tmp_cursor into tmp_name; end while; close tmp_cursor; end$$delimiter ;
其它类似信息

推荐信息