建表:mysql 电子商城建表参考
其他
2018-06-08 05:07:29
阅读次数: 2
-
- drop database if exists haoyigou;
- create database haoyigou charset utf8;
- use haoyigou;
-
-
- drop table if exists hyg_admin;
- create table hyg_admin(
- id tinyint unsigned auto_increment key comment 'id',
- username varchar(20) not null unique comment '用户名',
- password char(32) not null comment '用户密码:md5加密',
- email varchar(50) not null comment '邮箱地址'
- );
-
- insert into hyg_admin values(null,'admin',md5('admin'),'[email protected]');
-
-
- drop table if exists hyg_user;
- create table hyg_user(
- hyg_id int primary key auto_increment comment '主键',
- hyg_username varchar(20) not null unique comment '用户名必须唯一',
- hyg_password char(32) not null comment '用户密码:md5加密',
- hyg_email varchar(50) not null comment '邮箱地址'
- )charset utf8;
-
- insert into hyg_user values(null,'admin',md5('admin'),'[email protected]');
-
-
- drop table if exists hyg_delivery;
- create table hyg_delivery(
- user_id int comment '用户id',
- hyg_name varchar(10) comment '收货人姓名',
- hyg_phone varchar(11) comment '手机',
- hyg_postcode char(10) comment '邮政编码',
- hyg_addr varchar(30) comment '详细地址',
- hyg_time varchar(30) comment '送货时间'
- )charset utf8;
-
-
- INSERT INTO `haoyigou`.`hyg_delivery` (`user_id`, `hyg_name`, `hyg_phone`, `hyg_postcode`, `hyg_addr`, `hyg_time`) VALUES ('1', '黄晓明', '15878521654', '525300', '广东省广州市天河街道11', '不限');
-
- drop table if exists hyg_goods;
- create table hyg_goods(
- goods_id int primary key auto_increment comment '主键',
- goods_name varchar(120) comment '商品名称',
- cat_id smallint(5) comment '栏目id',
- brand_id int comment '品牌id',
- goods_score int comment '可使用积分',
- goods_sn varchar(60) comment '货号',
- goods_number int comment '库存量',
- shop_mprice decimal(10,2) comment '市场价格',
- shop_price decimal(10,2) comment '本店价格',
- goods_desc text comment '商品详细描述',
- add_time int comment '上架时间',
- ud_time int comment '更新时间',
- is_delete tinyint(1) comment '是否已删除',
- goods_image varchar(255) comment '图片名称',
- goods_thumb varchar(255) comment '缩略图名称',
- goods_sthumb varchar(255) comment '小缩略图片名称',
- is_best tinyint(1) comment '是否精品',
- is_new tinyint(1) comment '是否新品',
- is_hot tinyint(1) comment '是否热销',
- is_promote tinyint(1) comment '低价促销'
- )charset utf8;
-
- INSERT INTO `haoyigou`.`hyg_goods` (`goods_id`, `goods_name`, `cat_id`, `brand_id`, `goods_score`, `goods_sn`, `goods_number`, `shop_mprice`, `shop_price`, `goods_desc`, `add_time`, `ud_time`, `is_delete`, `goods_image`, `goods_thumb`, `goods_sthumb`, `is_best`, `is_new`, `is_hot`, `is_promote`) VALUES (NULL, 'iphone8', '1', '2', '1200', 'hyg_20152612', '11', '9000', '8000', '一步好手机', '12345678', '58495621', '0', '17_P_1241969394354.jpg', '17_thumb_P_1241969394537.jpg', 'small_thumb_P_1241969394537.jpg', '1', '1', '1', '1');
- INSERT INTO `haoyigou`.`hyg_goods` (`goods_id`, `goods_name`, `cat_id`, `brand_id`, `goods_score`, `goods_sn`, `goods_number`, `shop_mprice`, `shop_price`, `goods_desc`, `add_time`, `ud_time`, `is_delete`, `goods_image`, `goods_thumb`, `goods_sthumb`, `is_best`, `is_new`, `is_hot`, `is_promote`) VALUES (NULL, 'iphone8', '1', '2', '1200', 'hyg_20152612', '11', '9000', '8000', '强大手机的日常', '12345678', '58495621', '0', '17_P_1241969394354.jpg', '17_thumb_P_1241969394537.jpg', 'small_thumb_P_1241969394537.jpg', '0', '0', '0', '0');
-
-
- drop table if exists hyg_category;
- create table hyg_category(
- cat_id int primary key auto_increment comment '主键',
- cat_name varchar(30) comment '栏目名称',
- parent_id int comment '栏目的父id'
-
- )charset utf8;
-
-
- drop table if exists hyg_brand;
- create table hyg_brand(
- brd_id int primary key auto_increment comment '主键',
- cat_name varchar(30) comment '品牌名称'
- )charset utf8;
-
- insert into hyg_brand values(null,'诺基亚'),(null,'三星'),(null,'苹果');
-
-
- drop table if exists shop_album;
- create table shop_album(
- id int unsigned auto_increment key comment 'id',
- pid int unsigned not null comment '商品id',
- albumPath varchar(50) not null comment '图片路径',
- goods_sthumb varchar(255) comment '小缩略图片名称'
- );
-
-
-
- drop table if exists hyg_message;
- create table hyg_message(
- message_id int primary key auto_increment comment '自增',
- user_id int comment '留言用户的id',
- goods_id int default '0' comment '所在商品id,0代表网站留言',
- message_type int comment '留言类型: 留言 投诉 询问 售后 求购',
- message_content text comment '留言内容',
- message_date int comment '留言时间'
- )charset utf8;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- drop table if exists hyg_order;
- create table hyg_order(
- id int primary key auto_increment comment '自增',
- order_id varchar(30) comment '订单号',
- user_id int comment '用户id',
- order_good text comment '拼凑商品id和数量:1|3-2|1',
- order_time int comment '下单时间(时间戳)',
- order_money decimal(10,2) comment '订单金额',
- hyg_name varchar(10) comment '收货人姓名',
- hyg_phone varchar(11) comment '手机',
- hyg_postcode char(10) default '' comment '邮政编码',
- hyg_addr varchar(30) comment '详细地址',
- order_stat tinyint default '1' comment '订单状态',
- order_exp tinyint default '1' comment '送货方式',
- order_pay tinyint default '1' comment '支付方式',
- order_mes varchar(50) default '' comment '订单留言'
- )charset utf8;
-
-
-
-
-
-
-
-
-
-
-
- insert into hyg_order values(null,'hyg_00000001','1','1|3-2|1','20150126','500','小王','15845261547','512515','中国广东广州天朗明居',default,default,default,'尽快发货!');
- insert into hyg_order values(null,'hyg_00000002','2','2|1-2|2','20150127','500','小王','15845261547','512515','中国广东广州塘东',default,default,default,'期待!');
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- drop table if exists hyg_cart;
- create table hyg_cart(
- cart_id int primary key auto_increment comment '自增',
- u_id int not null comment '买家id',
- goods_id int comment '商品的id',
- price_count int comment '金额小计',
- mprice_count int comment '市场价格小计',
- sale_num int comment '购买数量'
- )charset utf8;
-
- INSERT INTO `haoyigou`.`hyg_cart` VALUES (NULL, '1', '1', '16000','18000','2');
- INSERT INTO `haoyigou`.`hyg_cart` VALUES (NULL , '2', '2', '16000','18000','1');
-
-
- create table hyg_college(
- id int primary key auto_increment comment '主键',
- user_id int comment '用户id',
- goods_id int comment '商品id'
-
- )charset utf8;
-
-
-
- alter table hyg_category add cat_sort tinyint default 20 comment '手机分类排序';
-
- drop database if exists haoyigou;
- create database haoyigou charset utf8;
- use haoyigou;
-
-
- drop table if exists hyg_admin;
- create table hyg_admin(
- id tinyint unsigned auto_increment key comment 'id',
- username varchar(20) not null unique comment '用户名',
- password char(32) not null comment '用户密码:md5加密',
- email varchar(50) not null comment '邮箱地址'
- );
-
- insert into hyg_admin values(null,'admin',md5('admin'),'[email protected]');
-
-
- drop table if exists hyg_user;
- create table hyg_user(
- hyg_id int primary key auto_increment comment '主键',
- hyg_username varchar(20) not null unique comment '用户名必须唯一',
- hyg_password char(32) not null comment '用户密码:md5加密',
- hyg_email varchar(50) not null comment '邮箱地址'
- )charset utf8;
-
- insert into hyg_user values(null,'admin',md5('admin'),'[email protected]');
-
-
- drop table if exists hyg_delivery;
- create table hyg_delivery(
- user_id int comment '用户id',
- hyg_name varchar(10) comment '收货人姓名',
- hyg_phone varchar(11) comment '手机',
- hyg_postcode char(10) comment '邮政编码',
- hyg_addr varchar(30) comment '详细地址',
- hyg_time varchar(30) comment '送货时间'
- )charset utf8;
-
-
- INSERT INTO `haoyigou`.`hyg_delivery` (`user_id`, `hyg_name`, `hyg_phone`, `hyg_postcode`, `hyg_addr`, `hyg_time`) VALUES ('1', '黄晓明', '15878521654', '525300', '广东省广州市天河街道11', '不限');
-
- drop table if exists hyg_goods;
- create table hyg_goods(
- goods_id int primary key auto_increment comment '主键',
- goods_name varchar(120) comment '商品名称',
- cat_id smallint(5) comment '栏目id',
- brand_id int comment '品牌id',
- goods_score int comment '可使用积分',
- goods_sn varchar(60) comment '货号',
- goods_number int comment '库存量',
- shop_mprice decimal(10,2) comment '市场价格',
- shop_price decimal(10,2) comment '本店价格',
- goods_desc text comment '商品详细描述',
- add_time int comment '上架时间',
- ud_time int comment '更新时间',
- is_delete tinyint(1) comment '是否已删除',
- goods_image varchar(255) comment '图片名称',
- goods_thumb varchar(255) comment '缩略图名称',
- goods_sthumb varchar(255) comment '小缩略图片名称',
- is_best tinyint(1) comment '是否精品',
- is_new tinyint(1) comment '是否新品',
- is_hot tinyint(1) comment '是否热销',
- is_promote tinyint(1) comment '低价促销'
- )charset utf8;
-
- INSERT INTO `haoyigou`.`hyg_goods` (`goods_id`, `goods_name`, `cat_id`, `brand_id`, `goods_score`, `goods_sn`, `goods_number`, `shop_mprice`, `shop_price`, `goods_desc`, `add_time`, `ud_time`, `is_delete`, `goods_image`, `goods_thumb`, `goods_sthumb`, `is_best`, `is_new`, `is_hot`, `is_promote`) VALUES (NULL, 'iphone8', '1', '2', '1200', 'hyg_20152612', '11', '9000', '8000', '一步好手机', '12345678', '58495621', '0', '17_P_1241969394354.jpg', '17_thumb_P_1241969394537.jpg', 'small_thumb_P_1241969394537.jpg', '1', '1', '1', '1');
- INSERT INTO `haoyigou`.`hyg_goods` (`goods_id`, `goods_name`, `cat_id`, `brand_id`, `goods_score`, `goods_sn`, `goods_number`, `shop_mprice`, `shop_price`, `goods_desc`, `add_time`, `ud_time`, `is_delete`, `goods_image`, `goods_thumb`, `goods_sthumb`, `is_best`, `is_new`, `is_hot`, `is_promote`) VALUES (NULL, 'iphone8', '1', '2', '1200', 'hyg_20152612', '11', '9000', '8000', '强大手机的日常', '12345678', '58495621', '0', '17_P_1241969394354.jpg', '17_thumb_P_1241969394537.jpg', 'small_thumb_P_1241969394537.jpg', '0', '0', '0', '0');
-
-
- drop table if exists hyg_category;
- create table hyg_category(
- cat_id int primary key auto_increment comment '主键',
- cat_name varchar(30) comment '栏目名称',
- parent_id int comment '栏目的父id'
-
- )charset utf8;
-
-
- drop table if exists hyg_brand;
- create table hyg_brand(
- brd_id int primary key auto_increment comment '主键',
- cat_name varchar(30) comment '品牌名称'
- )charset utf8;
-
- insert into hyg_brand values(null,'诺基亚'),(null,'三星'),(null,'苹果');
-
-
- drop table if exists shop_album;
- create table shop_album(
- id int unsigned auto_increment key comment 'id',
- pid int unsigned not null comment '商品id',
- albumPath varchar(50) not null comment '图片路径',
- goods_sthumb varchar(255) comment '小缩略图片名称'
- );
-
-
-
- drop table if exists hyg_message;
- create table hyg_message(
- message_id int primary key auto_increment comment '自增',
- user_id int comment '留言用户的id',
- goods_id int default '0' comment '所在商品id,0代表网站留言',
- message_type int comment '留言类型: 留言 投诉 询问 售后 求购',
- message_content text comment '留言内容',
- message_date int comment '留言时间'
- )charset utf8;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- drop table if exists hyg_order;
- create table hyg_order(
- id int primary key auto_increment comment '自增',
- order_id varchar(30) comment '订单号',
- user_id int comment '用户id',
- order_good text comment '拼凑商品id和数量:1|3-2|1',
- order_time int comment '下单时间(时间戳)',
- order_money decimal(10,2) comment '订单金额',
- hyg_name varchar(10) comment '收货人姓名',
- hyg_phone varchar(11) comment '手机',
- hyg_postcode char(10) default '' comment '邮政编码',
- hyg_addr varchar(30) comment '详细地址',
- order_stat tinyint default '1' comment '订单状态',
- order_exp tinyint default '1' comment '送货方式',
- order_pay tinyint default '1' comment '支付方式',
- order_mes varchar(50) default '' comment '订单留言'
- )charset utf8;
-
-
-
-
-
-
-
-
-
-
-
- insert into hyg_order values(null,'hyg_00000001','1','1|3-2|1','20150126','500','小王','15845261547','512515','中国广东广州天朗明居',default,default,default,'尽快发货!');
- insert into hyg_order values(null,'hyg_00000002','2','2|1-2|2','20150127','500','小王','15845261547','512515','中国广东广州塘东',default,default,default,'期待!');
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- drop table if exists hyg_cart;
- create table hyg_cart(
- cart_id int primary key auto_increment comment '自增',
- u_id int not null comment '买家id',
- goods_id int comment '商品的id',
- price_count int comment '金额小计',
- mprice_count int comment '市场价格小计',
- sale_num int comment '购买数量'
- )charset utf8;
-
- INSERT INTO `haoyigou`.`hyg_cart` VALUES (NULL, '1', '1', '16000','18000','2');
- INSERT INTO `haoyigou`.`hyg_cart` VALUES (NULL , '2', '2', '16000','18000','1');
-
-
- create table hyg_college(
- id int primary key auto_increment comment '主键',
- user_id int comment '用户id',
- goods_id int comment '商品id'
-
- )charset utf8;
-
-
-
- alter table hyg_category add cat_sort tinyint default 20 comment '手机分类排序';
转载自blog.csdn.net/qq_34306360/article/details/79721660