mysql自增长初始值设定
我查询一张表的最大id,之后清空表数据,并设定表的自增长初始值为该最大id,不知道哪出问题了,求大神指导
--------------------------------------------
create procedure prc_alter()
BEGIN
declare var_increamentId BIGINT DEFAULT 0;
set var_increamentId := (select max(id) from ia_track_month);
TRUNCATE table ia_track_month;
alter table ia_track_month auto_increment = var_increamentId;
commit;
end;
------解决方案--------------------
SET @asql=CONCAT('alter table ia_track_month auto_increment =',var_increamentId);
PREPARE stml FROM @asql;
EXECUTE stml;
------解决方案--------------------create procedure prc_alter()
BEGIN
declare var_increamentId BIGINT DEFAULT 0;
set var_increamentId := (select max(id) from ia_track_month);
TRUNCATE table ia_track_month;
SET @asql=CONCAT('alter table ia_track_month auto_increment =',var_increamentId);
PREPARE stml FROM @asql;
EXECUTE stml;
end;