-- 创建数据库 drop database if exists dbmgame_test; create database dbmgame_test; use dbmgame_test; -- 结束符 delimiter $$ -- 用户表,字段含义参见协议定义 CREATE procedure create_table() BEGIN DECLARE `@i` int(11); DECLARE `@sqlstr` varchar(2560); SET `@i`= 1; WHILE `@i` <= 100 DO SET @sqlstr = CONCAT( "create table tbuser_", `@i`, "( `uid` bigint not null, `realm` int not null, `nick` varchar(64) not null default '', `gender` int not null default 0, `icon` varchar(200) not null default '', `exp` int not null default 0, `level` int not null default 0, `vipLevel` int not null default 0, `vipExp` int not null default 0, `chip` bigint not null default 0, `diamond` bigint not null default 0, `lastLoginTime` bigint not null default 0, `createTime` bigint not null default 0, `onlineTime` bigint not null default 0, `firebasePushId` varchar(256) not null default '', `freezeTime` bigint not null default 0, `lang` varchar(16) not null default '', `heroExpPool` int(11) NOT NULL DEFAULT 0, `roleCreateComplete` int(11) NOT NULL DEFAULT 0, `power` int(11) NOT NULL DEFAULT 0, `unionId` bigint not null default 0, `gameData` mediumblob, `unimportanceData` mediumblob, primary key (`uid`), index `idx_realm_level`(`realm`, `level`), index (`nick`) ) engine=InnoDB default charset=utf8;" ); prepare stmt from @sqlstr; execute stmt; SET `@i` = `@i` + 1; END WHILE; END; call create_table(); drop procedure create_table; $$ -- 恢复结束符; delimiter ;