This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
This script is for updating the auto_increment field by an offset. The logic applied is | |
max(AUTO_INCREMENT) + current value in the table. | |
*/ | |
SET @db:='id_new'; | |
select @max_id:=max(AUTO_INCREMENT) from information_schema.tables; | |
select concat('update ',table_name,' set ', column_name,' = ',column_name,'+',@max_id,' ; ') from information_schema.columns where table_schema=@db and column_name like '%id' into outfile 'update_ids.sql'; |