修复mysql数据库自增字段的AUTO_INCREMENT起始值的存储过程_MySQL
来源:懂视网
责编:小采
时间:2020-11-09 19:27:19
修复mysql数据库自增字段的AUTO_INCREMENT起始值的存储过程_MySQL
修复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
导读修复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
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 ;
声明:本网页内容旨在传播知识,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。TEL:177 7030 7066 E-MAIL:11247931@qq.com
修复mysql数据库自增字段的AUTO_INCREMENT起始值的存储过程_MySQL
修复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