如上,需要创建xxx_00、xxx_01...xxx_99,格式相同,有没有快速建表语句啊,不需要一个一个的创建,试了下不行CREATE TABLE xxx_00,xxx_01,xxx_02...这样是语法错误的

解决方案 »

  1.   

    写个存储过程,然后调用;
    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;    
      
      

  2.   

    for i in `seq 1 100`
    do
    mysql -uroot -pxxx dbname -e "create table xxx_$i(a int)"
    done
      

  3.   


    DELIMITER //   
    CREATE PROCEDURE demo_in_test(IN p_in int)   
     BEGIN   
      declare i int;
      set i=0;
      while i<p_in do
          set @sql=concat('create table xxx_',i,'(a int)');
          prepare stmt from @sql;
          execute stmt;
      set i=i+1;
      end while;  
     END;   
      

  4.   

    可以利用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, c int, f1 int);
    CREATE TABLE xxx_55 (id int primary key, c int, f1 int);
    CREATE TABLE xxx_56 (id int primary key, c int, f1 int);
    CREATE TABLE xxx_57 (id int primary key, c int, f1 int);
    CREATE TABLE xxx_58 (id int primary key, c int, f1 int);
    CREATE TABLE xxx_59 (id int primary key, c int, f1 int);
    CREATE TABLE xxx_60 (id int primary key, c int, f1 int);
    CREATE TABLE xxx_61 (id int primary key, c int, f1 int);
    CREATE TABLE xxx_62 (id int primary key, c int, f1 int);
    CREATE TABLE xxx_63 (id int primary key, c int, f1 int);
    CREATE TABLE xxx_64 (id int primary key, c int, f1 int);
    CREATE TABLE xxx_65 (id int primary key, c int, f1 int);
    CREATE TABLE xxx_66 (id int primary key, c int, f1 int);
    CREATE TABLE xxx_67 (id int primary key, c int, f1 int);
    CREATE TABLE xxx_68 (id int primary key, c int, f1 int);
    CREATE TABLE xxx_69 (id int primary key, c int, f1 int);
    CREATE TABLE xxx_70 (id int primary key, c int, f1 int);
    CREATE TABLE xxx_71 (id int primary key, c int, f1 int);
    CREATE TABLE xxx_72 (id int primary key, c int, f1 int);
    CREATE TABLE xxx_73 (id int primary key, c int, f1 int);
    CREATE TABLE xxx_74 (id int primary key, c int, f1 int);
    CREATE TABLE xxx_75 (id int primary key, c int, f1 int);
    CREATE TABLE xxx_76 (id int primary key, c int, f1 int);
    CREATE TABLE xxx_77 (id int primary key, c int, f1 int);
    CREATE TABLE xxx_78 (id int primary key, c int, f1 int);
    CREATE TABLE xxx_79 (id int primary key, c int, f1 int);
    CREATE TABLE xxx_80 (id int primary key, c int, f1 int);
    CREATE TABLE xxx_81 (id int primary key, c int, f1 int);
    CREATE TABLE xxx_82 (id int primary key, c int, f1 int);
    CREATE TABLE xxx_83 (id int primary key, c int, f1 int);
    CREATE TABLE xxx_84 (id int primary key, c int, f1 int);
    CREATE TABLE xxx_85 (id int primary key, c int, f1 int);
    CREATE TABLE xxx_86 (id int primary key, c int, f1 int);
    CREATE TABLE xxx_87 (id int primary key, c int, f1 int);
    CREATE TABLE xxx_88 (id int primary key, c int, f1 int);
    CREATE TABLE xxx_89 (id int primary key, c int, f1 int);
    CREATE TABLE xxx_90 (id int primary key, c int, f1 int);
    CREATE TABLE xxx_91 (id int primary key, c int, f1 int);
    CREATE TABLE xxx_92 (id int primary key, c int, f1 int);
    CREATE TABLE xxx_93 (id int primary key, c int, f1 int);
    CREATE TABLE xxx_94 (id int primary key, c int, f1 int);
    CREATE TABLE xxx_95 (id int primary key, c int, f1 int);
    CREATE TABLE xxx_96 (id int primary key, c int, f1 int);
    CREATE TABLE xxx_97 (id int primary key, c int, f1 int);
    CREATE TABLE xxx_98 (id int primary key, c int, f1 int);
    CREATE TABLE xxx_99 (id int primary key, c int, f1 int);
      

  5.   

    for /l %%i in (1,1,10) do (d:\mysql55\bin\mysql -uroot -p123 aa -e "create table xxx_%%i(a int)" )
      

  6.   


    你这做法跟我公司一位同仁很相似,每次更新或者是insert数据他就用excel生成几千行的代码,然后执行。