重置AUTO_INCREMENT后,Mysql表消失。这是我用来重置auto_increment字段的过程。为什么它消失了?我做错了什么。当我检查/ var / lib / mysql / database_name时,我看到该表的文件!
DROP PROCEDURE IF EXISTS set_auto_increment;
DELIMITER //
CREATE PROCEDURE set_auto_increment (_table VARCHAR(64), _inc INT)
BEGIN
DECLARE _stmt VARCHAR(1024);
SET @SQL := CONCAT('ALTER TABLE ', _table, ' AUTO_INCREMENT = ', _inc);
PREPARE _stmt FROM @SQL;
EXECUTE _stmt;
DEALLOCATE PREPARE _stmt;
END//
DELIMITER ;
我在做:
select max(id)
into p_max
from table_name;
if p_max is not null then
call set_auto_increment('table_name',p_max);
end if;