美文网首页
mnysql批量插入数据

mnysql批量插入数据

作者: think_lonely | 来源:发表于2017-12-25 11:01 被阅读10次

    a.创建.sql文件insert_data.sql;

    drop database if exists insertData;

    create database insertData;

    use insertData;

    SET max_heap_table_size = 1024*1024*2000;//必要的配置,为MySQL分配更大的内存,便于存储

    CREATE TABLE InsertTable (

    `id` int(11) NOT NULL auto_increment,

    `name` varchar(50) default NULL,

    PRIMARY KEY (`id`)

    ) ENGINE=MEMORY DEFAULT CHARSET=utf8;

    delimiter @

    create procedure insert_InsertTable(in item integer)

    begin

    declare counter int;

    set counter = item;

    while counter >= 1 do

    insert into InsertTable values(counter,concat('Record.',counter));

    set counter = counter - 1;

    end while;

    end

    @

    delimiter @

    call insert_InsertTable(10000000);

    @

    b.调用.sql文件;

    mysql -u root -p

    c.查数据是否插入;

    select count(*) from InsertTable;

    相关文章

      网友评论

          本文标题:mnysql批量插入数据

          本文链接:https://www.haomeiwen.com/subject/ypgkgxtx.html