0
点赞
收藏
分享

微信扫一扫

建库、建表、造数据(微服务实战项目部分示例)

佳简诚锄 2022-02-17 阅读 39



建库

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);





============================= 提升自己 ==========================

如有侵权,请联系删除。

============================= 升职加薪 ==========================


举报

相关推荐

0 条评论