文件
mashangyoujiu/alcohol_categories_import.sql

138 行
8.8 KiB
SQL

-- 酒类商品两级分类层级数据导入脚本
-- 生成时间: 2024年
-- 说明: 包含6个一级分类和27个二级分类,共33个分类
-- 清理可能存在的测试数据(可选)
-- DELETE FROM ls_retail_goods_class WHERE id BETWEEN 1001 AND 1999;
-- 插入一级分类数据
-- 白酒分类
INSERT INTO ls_retail_goods_class (id, class_name, pid, type, status, code, is_recommend, addtime, merchantid, store_id, industry_id, add_type, banner_id)
VALUES (1001, '白酒', 0, 1, 1, 1001, 1, UNIX_TIMESTAMP(), 1, 0, 0, 1, 0);
-- 红酒分类
INSERT INTO ls_retail_goods_class (id, class_name, pid, type, status, code, is_recommend, addtime, merchantid, store_id, industry_id, add_type, banner_id)
VALUES (1002, '红酒', 0, 1, 1, 1002, 1, UNIX_TIMESTAMP(), 1, 0, 0, 1, 0);
-- 啤酒分类
INSERT INTO ls_retail_goods_class (id, class_name, pid, type, status, code, is_recommend, addtime, merchantid, store_id, industry_id, add_type, banner_id)
VALUES (1003, '啤酒', 0, 1, 1, 1003, 1, UNIX_TIMESTAMP(), 1, 0, 0, 1, 0);
-- 洋酒分类
INSERT INTO ls_retail_goods_class (id, class_name, pid, type, status, code, is_recommend, addtime, merchantid, store_id, industry_id, add_type, banner_id)
VALUES (1004, '洋酒', 0, 1, 1, 1004, 1, UNIX_TIMESTAMP(), 1, 0, 0, 1, 0);
-- 黄酒分类
INSERT INTO ls_retail_goods_class (id, class_name, pid, type, status, code, is_recommend, addtime, merchantid, store_id, industry_id, add_type, banner_id)
VALUES (1005, '黄酒', 0, 1, 1, 1005, 0, UNIX_TIMESTAMP(), 1, 0, 0, 1, 0);
-- 果酒分类
INSERT INTO ls_retail_goods_class (id, class_name, pid, type, status, code, is_recommend, addtime, merchantid, store_id, industry_id, add_type, banner_id)
VALUES (1006, '果酒', 0, 1, 1, 1006, 0, UNIX_TIMESTAMP(), 1, 0, 0, 1, 0);
-- 插入二级分类数据
-- 白酒子分类
INSERT INTO ls_retail_goods_class (id, class_name, pid, type, status, code, is_recommend, addtime, merchantid, store_id, industry_id, add_type, banner_id)
VALUES (1101, '浓香型白酒', 1001, 2, 1, 1101, 0, UNIX_TIMESTAMP(), 1, 0, 0, 1, 0);
INSERT INTO ls_retail_goods_class (id, class_name, pid, type, status, code, is_recommend, addtime, merchantid, store_id, industry_id, add_type, banner_id)
VALUES (1102, '酱香型白酒', 1001, 2, 1, 1102, 0, UNIX_TIMESTAMP(), 1, 0, 0, 1, 0);
INSERT INTO ls_retail_goods_class (id, class_name, pid, type, status, code, is_recommend, addtime, merchantid, store_id, industry_id, add_type, banner_id)
VALUES (1103, '清香型白酒', 1001, 2, 1, 1103, 0, UNIX_TIMESTAMP(), 1, 0, 0, 1, 0);
INSERT INTO ls_retail_goods_class (id, class_name, pid, type, status, code, is_recommend, addtime, merchantid, store_id, industry_id, add_type, banner_id)
VALUES (1104, '米香型白酒', 1001, 2, 1, 1104, 0, UNIX_TIMESTAMP(), 1, 0, 0, 1, 0);
INSERT INTO ls_retail_goods_class (id, class_name, pid, type, status, code, is_recommend, addtime, merchantid, store_id, industry_id, add_type, banner_id)
VALUES (1105, '兼香型白酒', 1001, 2, 1, 1105, 0, UNIX_TIMESTAMP(), 1, 0, 0, 1, 0);
-- 红酒子分类
INSERT INTO ls_retail_goods_class (id, class_name, pid, type, status, code, is_recommend, addtime, merchantid, store_id, industry_id, add_type, banner_id)
VALUES (1201, '干红葡萄酒', 1002, 2, 1, 1201, 0, UNIX_TIMESTAMP(), 1, 0, 0, 1, 0);
INSERT INTO ls_retail_goods_class (id, class_name, pid, type, status, code, is_recommend, addtime, merchantid, store_id, industry_id, add_type, banner_id)
VALUES (1202, '半干红葡萄酒', 1002, 2, 1, 1202, 0, UNIX_TIMESTAMP(), 1, 0, 0, 1, 0);
INSERT INTO ls_retail_goods_class (id, class_name, pid, type, status, code, is_recommend, addtime, merchantid, store_id, industry_id, add_type, banner_id)
VALUES (1203, '半甜红葡萄酒', 1002, 2, 1, 1203, 0, UNIX_TIMESTAMP(), 1, 0, 0, 1, 0);
INSERT INTO ls_retail_goods_class (id, class_name, pid, type, status, code, is_recommend, addtime, merchantid, store_id, industry_id, add_type, banner_id)
VALUES (1204, '甜红葡萄酒', 1002, 2, 1, 1204, 0, UNIX_TIMESTAMP(), 1, 0, 0, 1, 0);
-- 啤酒子分类
INSERT INTO ls_retail_goods_class (id, class_name, pid, type, status, code, is_recommend, addtime, merchantid, store_id, industry_id, add_type, banner_id)
VALUES (1301, '淡色啤酒', 1003, 2, 1, 1301, 0, UNIX_TIMESTAMP(), 1, 0, 0, 1, 0);
INSERT INTO ls_retail_goods_class (id, class_name, pid, type, status, code, is_recommend, addtime, merchantid, store_id, industry_id, add_type, banner_id)
VALUES (1302, '浓色啤酒', 1003, 2, 1, 1302, 0, UNIX_TIMESTAMP(), 1, 0, 0, 1, 0);
INSERT INTO ls_retail_goods_class (id, class_name, pid, type, status, code, is_recommend, addtime, merchantid, store_id, industry_id, add_type, banner_id)
VALUES (1303, '黑啤酒', 1003, 2, 1, 1303, 0, UNIX_TIMESTAMP(), 1, 0, 0, 1, 0);
INSERT INTO ls_retail_goods_class (id, class_name, pid, type, status, code, is_recommend, addtime, merchantid, store_id, industry_id, add_type, banner_id)
VALUES (1304, '小麦啤酒', 1003, 2, 1, 1304, 0, UNIX_TIMESTAMP(), 1, 0, 0, 1, 0);
INSERT INTO ls_retail_goods_class (id, class_name, pid, type, status, code, is_recommend, addtime, merchantid, store_id, industry_id, add_type, banner_id)
VALUES (1305, '精酿啤酒', 1003, 2, 1, 1305, 0, UNIX_TIMESTAMP(), 1, 0, 0, 1, 0);
-- 洋酒子分类
INSERT INTO ls_retail_goods_class (id, class_name, pid, type, status, code, is_recommend, addtime, merchantid, store_id, industry_id, add_type, banner_id)
VALUES (1401, '威士忌', 1004, 2, 1, 1401, 0, UNIX_TIMESTAMP(), 1, 0, 0, 1, 0);
INSERT INTO ls_retail_goods_class (id, class_name, pid, type, status, code, is_recommend, addtime, merchantid, store_id, industry_id, add_type, banner_id)
VALUES (1402, '白兰地', 1004, 2, 1, 1402, 0, UNIX_TIMESTAMP(), 1, 0, 0, 1, 0);
INSERT INTO ls_retail_goods_class (id, class_name, pid, type, status, code, is_recommend, addtime, merchantid, store_id, industry_id, add_type, banner_id)
VALUES (1403, '伏特加', 1004, 2, 1, 1403, 0, UNIX_TIMESTAMP(), 1, 0, 0, 1, 0);
INSERT INTO ls_retail_goods_class (id, class_name, pid, type, status, code, is_recommend, addtime, merchantid, store_id, industry_id, add_type, banner_id)
VALUES (1404, '朗姆酒', 1004, 2, 1, 1404, 0, UNIX_TIMESTAMP(), 1, 0, 0, 1, 0);
-- 黄酒子分类
INSERT INTO ls_retail_goods_class (id, class_name, pid, type, status, code, is_recommend, addtime, merchantid, store_id, industry_id, add_type, banner_id)
VALUES (1501, '绍兴黄酒', 1005, 2, 1, 1501, 0, UNIX_TIMESTAMP(), 1, 0, 0, 1, 0);
INSERT INTO ls_retail_goods_class (id, class_name, pid, type, status, code, is_recommend, addtime, merchantid, store_id, industry_id, add_type, banner_id)
VALUES (1502, '客家黄酒', 1005, 2, 1, 1502, 0, UNIX_TIMESTAMP(), 1, 0, 0, 1, 0);
INSERT INTO ls_retail_goods_class (id, class_name, pid, type, status, code, is_recommend, addtime, merchantid, store_id, industry_id, add_type, banner_id)
VALUES (1503, '福建老酒', 1005, 2, 1, 1503, 0, UNIX_TIMESTAMP(), 1, 0, 0, 1, 0);
INSERT INTO ls_retail_goods_class (id, class_name, pid, type, status, code, is_recommend, addtime, merchantid, store_id, industry_id, add_type, banner_id)
VALUES (1504, '江西封缸酒', 1005, 2, 1, 1504, 0, UNIX_TIMESTAMP(), 1, 0, 0, 1, 0);
-- 果酒子分类
INSERT INTO ls_retail_goods_class (id, class_name, pid, type, status, code, is_recommend, addtime, merchantid, store_id, industry_id, add_type, banner_id)
VALUES (1601, '苹果酒', 1006, 2, 1, 1601, 0, UNIX_TIMESTAMP(), 1, 0, 0, 1, 0);
INSERT INTO ls_retail_goods_class (id, class_name, pid, type, status, code, is_recommend, addtime, merchantid, store_id, industry_id, add_type, banner_id)
VALUES (1602, '梅子酒', 1006, 2, 1, 1602, 0, UNIX_TIMESTAMP(), 1, 0, 0, 1, 0);
INSERT INTO ls_retail_goods_class (id, class_name, pid, type, status, code, is_recommend, addtime, merchantid, store_id, industry_id, add_type, banner_id)
VALUES (1603, '桃花酒', 1006, 2, 1, 1603, 0, UNIX_TIMESTAMP(), 1, 0, 0, 1, 0);
INSERT INTO ls_retail_goods_class (id, class_name, pid, type, status, code, is_recommend, addtime, merchantid, store_id, industry_id, add_type, banner_id)
VALUES (1604, '荔枝酒', 1006, 2, 1, 1604, 0, UNIX_TIMESTAMP(), 1, 0, 0, 1, 0);
INSERT INTO ls_retail_goods_class (id, class_name, pid, type, status, code, is_recommend, addtime, merchantid, store_id, industry_id, add_type, banner_id)
VALUES (1605, '葡萄果酒', 1006, 2, 1, 1605, 0, UNIX_TIMESTAMP(), 1, 0, 0, 1, 0);
-- 验证插入结果
-- SELECT
-- CASE WHEN pid = 0 THEN '一级分类' ELSE '二级分类' END as level_type,
-- id, class_name, pid, code
-- FROM ls_retail_goods_class
-- WHERE id BETWEEN 1001 AND 1999
-- ORDER BY pid, id;
-- 统计信息
-- SELECT
-- '总计' as category,
-- COUNT(*) as total_count,
-- COUNT(CASE WHEN pid = 0 THEN 1 END) as level1_count,
-- COUNT(CASE WHEN pid > 0 THEN 1 END) as level2_count
-- FROM ls_retail_goods_class
-- WHERE id BETWEEN 1001 AND 1999;