日期:2014-05-16  浏览次数:20902 次

创建100张相同格式的表,如何写sql
如上,需要创建xxx_00、xxx_01...xxx_99,格式相同,有没有快速建表语句啊,不需要一个一个的创建,试了下不行

CREATE TABLE xxx_00,xxx_01,xxx_02...这样是语法错误的

------解决方案--------------------
写个存储过程,然后调用;
DELIMITER //
CREATE PROCEDURE demo_in_test(IN p_in int)
 BEGIN
declare i int;
set i=0;
while i<p_in do
//这里写创建表的语句,表明当然是变化的哦
set i=i+1;
end while; 
 END;
  

------解决方案--------------------
可以利用EXCEL中生成如下语句。
CREATE TABLE xxx_00 (id int primary key, c int, f1 int);
CREATE TABLE xxx_01 (id int primary key, c int, f1 int);
CREATE TABLE xxx_02 (id int primary key, c int, f1 int);
CREATE TABLE xxx_03 (id int primary key, c int, f1 int);
CREATE TABLE xxx_04 (id int primary key, c int, f1 int);
CREATE TABLE xxx_05 (id int primary key, c int, f1 int);
CREATE TABLE xxx_06 (id int primary key, c int, f1 int);
CREATE TABLE xxx_07 (id int primary key, c int, f1 int);
CREATE TABLE xxx_08 (id int primary key, c int, f1 int);
CREATE TABLE xxx_09 (id int primary key, c int, f1 int);
CREATE TABLE xxx_10 (id int primary key, c int, f1 int);
CREATE TABLE xxx_11 (id int primary key, c int, f1 int);
CREATE TABLE xxx_12 (id int primary key, c int, f1 int);
CREATE TABLE xxx_13 (id int primary key, c int, f1 int);
CREATE TABLE xxx_14 (id int primary key, c int, f1 int);
CREATE TABLE xxx_15 (id int primary key, c int, f1 int);
CREATE TABLE xxx_16 (id int primary key, c int, f1 int);
CREATE TABLE xxx_17 (id int primary key, c int, f1 int);
CREATE TABLE xxx_18 (id int primary key, c int, f1 int);
CREATE TABLE xxx_19 (id int primary key, c int, f1 int);
CREATE TABLE xxx_20 (id int primary key, c int, f1 int);
CREATE TABLE xxx_21 (id int primary key, c int, f1 int);
CREATE TABLE xxx_22 (id int primary key, c int, f1 int);
CREATE TABLE xxx_23 (id int primary key, c int, f1 int);
CREATE TABLE xxx_24 (id int primary key, c int, f1 int);
CREATE TABLE xxx_25 (id int primary key, c int, f1 int);
CREATE TABLE xxx_26 (id int primary key, c int, f1 int);
CREATE TABLE xxx_27 (id int primary key, c int, f1 int);
CREATE TABLE xxx_28 (id int primary key, c int, f1 int);
CREATE TABLE xxx_29 (id int primary key, c int, f1 int);
CREATE TABLE xxx_30 (id int primary key, c int, f1 int);
CREATE TABLE xxx_31 (id int primary key, c int, f1 int);
CREATE TABLE xxx_32 (id int primary key, c int, f1 int);
CREATE TABLE xxx_33 (id int primary key, c int, f1 int);
CREATE TABLE xxx_34 (id int primary key, c int, f1 int);
CREATE TABLE xxx_35 (id int primary key, c int, f1 int);
CREATE TABLE xxx_36 (id int primary key, c int, f1 int);
CREATE TABLE xxx_37 (id int primary key, c int, f1 int);
CREATE TABLE xxx_38 (id int primary key, c int, f1 int);
CREATE TABLE xxx_39 (id int primary key, c int, f1 int);
CREATE TABLE xxx_40 (id int primary key, c int, f1 int);
CREATE TABLE xxx_41 (id int primary key, c int, f1 int);
CREATE TABLE xxx_42 (id int primary key, c int, f1 int);
CREATE TABLE xxx_43 (id int primary key, c int, f1 int);
CREATE TABLE xxx_44 (id int primary key, c int, f1 int);
CREATE TABLE xxx_45 (id int primary key, c int, f1 int);
CREATE TABLE xxx_46 (id int primary key, c int, f1 int);
CREATE TABLE xxx_47 (id int primary key, c int, f1 int);
CREATE TABLE xxx_48 (id int primary key, c int, f1 int);
CREATE TABLE xxx_49 (id int primary key, c int, f1 int);
CREATE TABLE xxx_50 (id int primary key, c int, f1 int);
CREATE TABLE xxx_51 (id int primary key, c int, f1 int);
CREATE TABLE xxx_52 (id int primary key, c int, f1 int);
CREATE TABLE xxx_53 (id int primary key, c int, f1 int);
CREATE TABLE xxx_54 (id int primary key,