Practice of mysql batch building database and table

1. The first way, simple and violent way

http://www.toolscat.com/dev/split-table

2. Manually create a stored procedure in the dbever page

See Create a stored procedure in dbever

Pit: delimiter, see: Solve the problem of declare error when mysql import stored procedure

3. Write the script in the dbever script

Solve the problem of prefix plus zero , another way

{ CALL database_name.createdatabase2() }

delimiter //
CREATE PROCEDURE `database_name`.`createdatabase2`()
BEGIN
set @j = 0;
while @j < 13 do
	if @j < 10 then
		set @count = CONCAT("0", @j);
	else
		set @count = CONCAT("",@j);
	end if;
#set @count = right(cast(power(10,3) as varchar) + 33,2);
	set @dbname = concat('aadatabase_',@count);
	set @sql_t = concat("CREATE DATABASE ",@dbname);
	prepare sql_t from @sql_t;
	execute sql_t;
	set @j = @j + 1;
end while;
END

 

Guess you like

Origin blog.csdn.net/qq_32907195/article/details/112323959