100W条假数据

首先一个客户的导入1W条商品数据

一个导出的数据库

一个导入的数据库

sql语句/造个过程函数

BEGIN
    
insert into goods_basic
(
`seller_id` ,
                        `goods_id` ,
                        `cate_sys_alias_id` ,
                        `goods_name` ,
                        `goods_no` ,
                        `type_goods` ,
                        `unit_weight` ,
                        `unit_sixze` ,
                        `unit_qty` ,
                        `manufacture_name` ,
                        `is_contain_std` ,
                        `is_deleted` ,
                        `createtime` ,
                        `create_user_id` ,
                        `updatetime` ,
                        `update_user_id` ,
                        `old_id`,
            `step`
)
SELECT
p_seller_id as `seller_id` ,
                        func_get_seq_no(p_seller_id,12) as `goods_id` ,
                        0 as `cate_sys_alias_id` ,
                        t1.pro_name as `goods_name` ,
                        t1.sku_num as `goods_no` ,
                        1 as `type_goods` ,
                        40 as `unit_weight` ,
                        52 as `unit_sixze` ,
                        54 as `unit_qty` ,
                        ‘rinhoo‘ as `manufacture_name` ,
                        0 as `is_contain_std` ,
                        0 as `is_deleted` ,
                        NOW() as `createtime` ,
                        171 as `create_user_id` ,
                        NOW() as `updatetime` ,
                        171 as `update_user_id` ,
                        t1.id as `old_id`,
            p_seller_id
 from
`site_rinhooOTA=`.rinhoo_products t1;

insert into goods_main_pics
            (
                `seller_id` ,
                `goods_id` ,
                `image_url` ,
                `image_big_name` ,
                `image_small_name` ,
                `image_tips` ,
                `is_main_image` ,
                `is_list_image` ,
                `is_visibled` ,
                `is_deleted`
            )
            select
                t2.seller_id as `seller_id` ,
                t2.goods_id as `goods_id` ,
                CONCAT(‘http://site2.shop-9yu.com/image/product/‘,SUBSTR(t1.img_path FROM 1 FOR 11)) as `image_url` ,
                SUBSTR(t1.img_path FROM 12) as `image_big_name` ,
                SUBSTR(t1.img_path FROM 12) as `image_small_name` ,
                t2.goods_name as `image_tips` ,
                t1.img_main as `is_main_image` ,
                0 as `is_list_image` ,
                1 as `is_visibled` ,
                0 as `is_deleted`
            from `site_rinhooOTA=`.rinhoo_products_photo t1
            INNER JOIN goods_basic t2
            on t1.pc_id = t2.old_id
      where step=p_seller_id;

insert into goods_desc
            (
                `seller_id` ,
                `goods_id` ,
                `goods_name_alias` ,
                `page_title` ,
                `page_keywords` ,
                `page_description` ,
                `goods_detail_desc` ,
                `weight_deliver_alias` ,
                `qty_store_alias`
            )
            select
                        t3.seller_id as `seller_id` ,
                        t3.goods_id as `goods_id` ,
                        t3.goods_name as `goods_name_alias` ,
                        t2.page_title as `page_title` ,
                        t2.page_keyword as `page_keywords` ,
                        t2.page_content as `page_description` ,
                        t1.content as `goods_detail_desc` ,
                        t2.weight as `weight_deliver_alias` ,
                        10 as `qty_store_alias`
            from `site_rinhooOTA=`.rinhoo_goods_seodesc t1
            INNER JOIN `site_rinhooOTA=`.rinhoo_products t2
            on t1.gid = t2.gid
            INNER JOIN goods_basic t3
            on t2.id = t3.old_id
      where step=p_seller_id;

insert into goods_std_extend_common
            (
                    `seller_id` ,
                    `goods_id` ,
                    `std_goods_id` ,
                    `qty_per_case` ,
                    `production_date` ,
                    `weight` ,
                    `length` ,
                    `width` ,
                    `height` ,
                    `sale_state` ,
                    `production_cycle` ,
                    `is_deleted`     
            )
            SELECT
                    t2.seller_id as `seller_id` ,
                    t2.goods_id as `goods_id` ,
                    0 as `std_goods_id` ,
                    0 as `qty_per_case` ,
                    ‘2015-03-11‘ as `production_date` ,
                    t1.weight as `weight` ,
                    t1.chang as `length` ,
                    t1.weight as `width` ,
                    t1.gao as `height` ,
                    1 as `sale_state` ,
                    360 as `production_cycle` ,
                    0 as `is_deleted`
            FROM `site_rinhooOTA=`.rinhoo_products t1
            INNER JOIN goods_basic t2
            on t1.id = t2.old_id
where step=p_seller_id;

insert into price_goods_supply
            (
                    `seller_id` ,
                    `goods_id` ,
                    `std_goods_id` ,
                    `cost_price` ,
                    `sale_price` ,
                    `dis_price` ,
                    `description`
            )
            SELECT
                    t2.seller_id as `seller_id` ,
                    t2.goods_id as `goods_id` ,
                    0 as `std_goods_id` ,
                    round(t1.cost * 100,0) as `cost_price` ,
                    round(t1.total_price*100,0) as `sale_price` ,
                    round(t1.cost * 1.30*100,0) as `dis_price` ,
                    ‘‘ as `description`
            from `site_rinhooOTA=`.rinhoo_products t1
            INNER JOIN goods_basic t2
            on t1.id = t2.old_id
where step=p_seller_id;

insert into price_goods_shop_supply
            (
                    `seller_id` ,
                    `shop_id`,
                    `goods_id` ,
                    `std_goods_id` ,
                    `cost_price` ,
                    `sale_price` ,
                    `bonus_sale` ,
                    `description`
            )
            SELECT
                    t2.seller_id as `seller_id` ,
                    1 as `shop_id`,
                    t2.goods_id as `goods_id` ,
                    0 as `std_goods_id` ,
                    round(t1.cost * 1.30*100,0) as `cost_price` ,
                    round(t1.total_price*100,0) as `sale_price` ,
                    0 as `bonus_sale`,
                    ‘‘ as `description`
            from `site_rinhooOTA=`.rinhoo_products t1
            INNER JOIN goods_basic t2
            on t1.id = t2.old_id
      where step=p_seller_id;

update goods_basic t0 INNER JOIN
(
SELECT t1.ct_id,t4.cate_sys_alias_id,t2.seller_id,t2.goods_id

from `site_rinhooOTA=`.rinhoo_products t1
INNER JOIN goods_basic t2
on t1.id = t2.old_id
INNER JOIN `site_rinhooOTA=`.rinhoo_category t3
on t1.ct_id = t3.id
LEFT OUTER JOIN category_sys_alias_en t4
on t3.ct_name = t4.cate_sys_name_alias
) Q1
on t0.seller_id = Q1.seller_id and t0.goods_id = Q1.goods_id
set t0.cate_sys_alias_id = Q1.cate_sys_alias_id,t0.old_ct_id = Q1.ct_id
where t0.step=p_seller_id;

insert into category_shop
(
`seller_id`,
`shop_id`,
`cate_shop_id`,
`level`,
`cate_name`,
`page_title`,
`page_keywords`,
`page_description`,
`image_url`,
`image_base_name`,
`image_tips`,
`cate_shop_index`,
`is_visible` ,
`old_sct_id_1`,
`old_sct_id_2`,
`old_sct_id_3`,
`old_sct_id_4`
)
SELECT
p_seller_id as `seller_id`,
1 as `shop_id`,
-- `p_sys_id_1` int,`p_sys_id_2` int,`p_sys_id_3` int,`p_sys_id_4` int,`p_sys_id_5` int,`p_seller_id` int,`p_shop_id` int
-- func_get_shop_cate_id(0,0,0,0,0,16777216,1) as `cate_shop_id`,
33554432 + (Q1.step-1)*33554432 as `cate_shop_id`,
t1.sct_deep as `level`,
t1.sct_name as `cate_name`,
t1.sct_name`page_title`,
t1.sct_name as `page_keywords`,
t1.sct_name as `page_description`,
‘‘ as `image_url`,
‘‘ as `image_base_name`,
t1.sct_name as `image_tips`,
99 as `cate_shop_index`,
1 as `is_visible`,
t1.id,
0,
0,
0
FROM
`site_rinhooOTA=`.rinhoo_shop_category t1
INNER JOIN(
SELECT t2.id,count(*) as step from `site_rinhooOTA=`.rinhoo_shop_category t2
INNER JOIN `site_rinhooOTA=`.rinhoo_shop_category t3
on t2.id >= t3.id
where t2.sct_deep = 1 and t3.sct_deep = 1
group by t2.id
) Q1
on t1.id = Q1.id;

insert into category_shop
(
`seller_id`,
`shop_id`,
`cate_shop_id`,
`level`,
`cate_name`,
`page_title`,
`page_keywords`,
`page_description`,
`image_url`,
`image_base_name`,
`image_tips`,
`cate_shop_index`,
`is_visible` ,
`old_sct_id_1`,
`old_sct_id_2`,
`old_sct_id_3`,
`old_sct_id_4`
)
SELECT
p_seller_id as `seller_id`,
1 as `shop_id`,
-- `p_sys_id_1` int,`p_sys_id_2` int,`p_sys_id_3` int,`p_sys_id_4` int,`p_sys_id_5` int,`p_seller_id` int,`p_shop_id` int
-- func_get_shop_cate_id(0,0,0,0,0,16777216,1) as `cate_shop_id`,
Q1.step as `cate_shop_id`,
t1.sct_deep as `level`,
t1.sct_name as `cate_name`,
t1.sct_name`page_title`,
t1.sct_name as `page_keywords`,
t1.sct_name as `page_description`,
‘‘ as `image_url`,
‘‘ as `image_base_name`,
t1.sct_name as `image_tips`,
99 as `cate_shop_index`,
1 as `is_visible`,
0,
t1.id,
0,
0
FROM
`site_rinhooOTA=`.rinhoo_shop_category t1
INNER JOIN(
SELECT t4.cate_shop_id,t2.id,func_get_shop_cate_id(t4.cate_shop_id,0,0,0,0,p_seller_id,1) + (count(*)-1)*1048576 as step from `site_rinhooOTA=`.rinhoo_shop_category t2
INNER JOIN `site_rinhooOTA=`.rinhoo_shop_category t3
on t2.sct_pid = t3.sct_pid and t2.id >= t3.id
INNER JOIN category_shop t4
on t2.sct_pid = t4.old_sct_id_1
where t4.seller_id=p_seller_id and  t2.sct_deep = 2 and t3.sct_deep = 2
group by t4.cate_shop_id,t2.id
) Q1
on t1.id = Q1.id;

insert into category_shop
(
`seller_id`,
`shop_id`,
`cate_shop_id`,
`level`,
`cate_name`,
`page_title`,
`page_keywords`,
`page_description`,
`image_url`,
`image_base_name`,
`image_tips`,
`cate_shop_index`,
`is_visible` ,
`old_sct_id_1`,
`old_sct_id_2`,
`old_sct_id_3`,
`old_sct_id_4`
)
SELECT
p_seller_id as `seller_id`,
1 as `shop_id`,
-- `p_sys_id_1` int,`p_sys_id_2` int,`p_sys_id_3` int,`p_sys_id_4` int,`p_sys_id_5` int,`p_seller_id` int,`p_shop_id` int
-- func_get_shop_cate_id(0,0,0,0,0,16777216,1) as `cate_shop_id`,
Q1.step as `cate_shop_id`,
t1.sct_deep as `level`,
t1.sct_name as `cate_name`,
t1.sct_name`page_title`,
t1.sct_name as `page_keywords`,
t1.sct_name as `page_description`,
‘‘ as `image_url`,
‘‘ as `image_base_name`,
t1.sct_name as `image_tips`,
99 as `cate_shop_index`,
1 as `is_visible`,
0,
0,
t1.id,
0
FROM
`site_rinhooOTA=`.rinhoo_shop_category t1
INNER JOIN(
SELECT t4.cate_shop_id,t2.id,func_get_shop_cate_id(0,t4.cate_shop_id,0,0,0,p_seller_id,1) + (count(*)-1)*32768 as step from `site_rinhooOTA=`.rinhoo_shop_category t2
INNER JOIN `site_rinhooOTA=`.rinhoo_shop_category t3
on t2.sct_pid = t3.sct_pid and t2.id >= t3.id
INNER JOIN category_shop t4
on t2.sct_pid = t4.old_sct_id_2
where t4.seller_id=p_seller_id and t2.sct_deep = 3 and t3.sct_deep = 3
group by t4.cate_shop_id,t2.id
) Q1
on t1.id = Q1.id;

insert into category_shop
(
`seller_id`,
`shop_id`,
`cate_shop_id`,
`level`,
`cate_name`,
`page_title`,
`page_keywords`,
`page_description`,
`image_url`,
`image_base_name`,
`image_tips`,
`cate_shop_index`,
`is_visible` ,
`old_sct_id_1`,
`old_sct_id_2`,
`old_sct_id_3`,
`old_sct_id_4`
)
SELECT
p_seller_id as `seller_id`,
1 as `shop_id`,
-- `p_sys_id_1` int,`p_sys_id_2` int,`p_sys_id_3` int,`p_sys_id_4` int,`p_sys_id_5` int,`p_seller_id` int,`p_shop_id` int
-- func_get_shop_cate_id(0,0,0,0,0,16777216,1) as `cate_shop_id`,
Q1.step as `cate_shop_id`,
t1.sct_deep as `level`,
t1.sct_name as `cate_name`,
t1.sct_name`page_title`,
t1.sct_name as `page_keywords`,
t1.sct_name as `page_description`,
‘‘ as `image_url`,
‘‘ as `image_base_name`,
t1.sct_name as `image_tips`,
99 as `cate_shop_index`,
1 as `is_visible`,
0,
0,
0,
t1.id
FROM
`site_rinhooOTA=`.rinhoo_shop_category t1
INNER JOIN(
SELECT t4.cate_shop_id,t2.id,func_get_shop_cate_id(0,0,t4.cate_shop_id,0,0,p_seller_id,1) + (count(*)-1)*1024 as step from `site_rinhooOTA=`.rinhoo_shop_category t2
INNER JOIN `site_rinhooOTA=`.rinhoo_shop_category t3
on t2.sct_pid = t3.sct_pid and t2.id >= t3.id
INNER JOIN category_shop t4
on t2.sct_pid = t4.old_sct_id_3
where t4.seller_id=p_seller_id and  t2.sct_deep = 4 and t3.sct_deep = 4
group by t4.cate_shop_id,t2.id
) Q1
on t1.id = Q1.id;

insert into relationship_shop_product
(
`shop_owner_id`,
`goods_id`,
`seller_shop_id`,
`cate_shop_id`,
`is_visible`,
`is_accept_price`,
`is_store_visible`,
`is_deleted`,
`create_time`,
`update_time`
)
SELECT
t2.seller_id,
t2.goods_id,
1,
t3.cate_shop_id,
1,
1,
1,
0,
NOW(),
NOW()
 from `site_rinhooOTA=`.rinhoo_products t1
INNER JOIN goods_basic t2
on t1.id = t2.old_id
INNER JOIN category_shop t3
on t1.sct_id in (t3.old_sct_id_1,t3.old_sct_id_2,t3.old_sct_id_3,t3.old_sct_id_4)
where t2.step=p_seller_id and t3.cate_shop_id is not null;

insert into goods_attr_item
(
`seller_id`,
`goods_id`,
`cate_attr_type`,
`cate_attr_id`,
`attr_item_cate_id`,
`goods_attr_item_value`,
`old_id`
)

SELECT
t3.seller_id,
t3.goods_id,
16,
t1.attr_cate_sys_id,
0,
‘‘,
t1.id

from rinhoo_products_sx t1
INNER JOIN goods_basic t3
on t1.pc_id = t3.old_id
WHERE t3.step=p_seller_id and t1.attr_cate_sys_id >0;

update goods_attr_item t1
INNER JOIN rinhoo_products_sx t2
on t1.old_id = t2.id and t2.attr_cate_sys_id > 0 and (t2.sx_type=1 or t2.attr_item_cate_id > 0)
set t1.attr_item_cate_id = t2.attr_item_cate_id,
t1.goods_attr_item_value = (case when t2.sx_type = 1 then t2.sv_name else ‘‘ end)
where t1.seller_id=p_seller_id;

END

通过开发那边单元测试生成100个客户

每个客户循环

造个存储过程

BEGIN  
    DECLARE m_seller_id INT; 
-- 遍历数据结束标志
  DECLARE done INT DEFAULT FALSE;
  -- 游标
  DECLARE cur CURSOR FOR select seller_id from seller_sys where seller_id > 875626496;        
  -- 将结束标志绑定到游标
  DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
         -- 打开游标
        OPEN cur;  
        -- 开始循环
        read_loop: LOOP
            -- 提取游标里的数据,这里只有一个,多个的话也一样;
            FETCH cur INTO m_seller_id;
            -- 声明结束的时候
            IF done THEN
                LEAVE read_loop;
            END IF;
            call proc_import_data_rinhoo(m_seller_id);//一个客户的导入的过程名字,有个传入参数
        END LOOP;
        -- 关闭游标
        CLOSE cur;

END

时间: 2024-08-11 14:01:14

100W条假数据的相关文章

Yii2 使用 faker 生成假数据

Yii2使用 faker 生成假数据. 1. config\console.php 中添加一条配置信息 'controllerMap' => [ 'fixture' => [ 'class' => 'yii\faker\FixtureController', ], ], 注意顶部,定义test测试目录的位置的代码. Yii::setAlias('@tests', dirname(__DIR__) . '/tests'); 2. 创建生成假信息的模版文件 在test目录下面依次新建unit

MySQL快速生成100W条测试数据

https://blog.csdn.net/qq_16946803/article/details/81870174 1.生成思路利用mysql内存表插入速度快的特点,先利用函数和存储过程在内存表中生成数据,然后再从内存表插入普通表中 2.创建普通表及内存表普通表CREATE TABLE `vote_record` ( `id` INT (11) NOT NULL AUTO_INCREMENT, `user_id` VARCHAR (20) NOT NULL, `vote_id` INT (11

laravel实践24.填充假数据

在实际的项目开发过程中,我们经常会用到一些假数据来对数据库进行填充以方便调试程序 假数据的生成分为两个阶段: 对要生成假数据的模型指定字段进行赋值 - 模型工厂: 批量生成假数据模型 - 数据填充: 1.建立模型工厂: database/factories/UserFactory.php use App\Models\User; use Illuminate\Support\Str; use Faker\Generator as Faker; $factory->define(User::cla

两个表联合查询获取聊天表中用户最新的一条聊天数据

一个用户表,一个聊天记录表,两个表联合查询获取聊天表中用户最新的一条聊天数据 select c.contentfrom sixin as c where c.tid = a.user_idorder by ctime desc limit 0,1) as content,(select c.statusfrom sixin as c where c.tid = a.user_idorder by ctime desc limit 0,1) as status from users as a, s

sql数据库中查询第几条到第几条的数据

通用方法: select top 500 * from (select top 1000 * from UserSearchDatas order by ID) a order by ID desc sql数据库中查询第几条到第几条的数据,布布扣,bubuko.com

asp 从第几条开始读取数据 asp跳过前几条读取数据

asp 从第几条开始读取数据 asp跳过前几条读取数据 <% set rs=server.CreateObject("adodb.recordset") sql="select top 15 * from jsyllh_xxnews where SMT_key=1 and SMT_newssort=41 order by SMT_id desc " rs.open sql,conn,1,1 if rs.eof then  response.write &quo

多条Json数据转换为泛型数据

/// <summary> /// 单条json数据转换为实体 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="str">字符窜(格式为{a:'',b:''})</param> /// <returns></returns> private static T ConvertToEnt

[lua, mysql] 将多条记录数据组合成一条sql插入语句(for mysql)

-- 演示将多条记录数据组合成一条sql插入语句(for mysql) function getTpl0(tname) -- 获取表各个字段 local t = { tpl_pack = {"packId","itemId","`group`","num","rate","rateType"}, } for k, v in pairs(t) do if tname == k then r

java+ mysql 给所有的表添加假数据

需求:别的项目, 代码扣过来了, 数据库也拿过来了, 但是数据库全是空表, 一共700 张表,需求是给表添加假数据,让它能运行起来. 一下是代码实现: 1.数据库连接: public static Connection getConnection(){ Connection conn = null; try { Class.forName("com.mysql.jdbc.Driver"); String url = "jdbc:mysql://192.168.0.12:330