建库
create database gifts charset utf8;
建表
product
CREATE TABLE `product` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`product_name` varchar(100) DEFAULT NULL COMMENT '商品名称',
`price` double(15,3) DEFAULT NULL COMMENT '商品价格',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4;
造数据
少量
insert into product(id,product_name,price) values (1,'笔记本电脑',6999.000),(2,'华为手机',2999.000),(3,'冰箱',3900.000),(4,'电视',2000.000);
大量 (10万)
drop procedure if exists insert_product;
delimiter $$
create procedure insert_product(in n INT)
BEGIN
declare product_name varchar(100) default 'product';
declare i int default 1;
while(i<n)do
insert into product(id,product_name,price) values(i,concat(product_name,i),i);
set i=i+1;
end while;
END $$
delimiter;
show create procedure insert_product;
call insert_product(100001);
【bak】https://www.cnblogs.com/uncleyong/p/15667258.html
更多:https://www.cnblogs.com/uncleyong/p/15475614.html