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;
网友评论