drop table if exists sms_category_bounds;
drop table if exists sms_coupon;
drop table if exists sms_coupon_history;
drop table if exists sms_coupon_spu_category_relation;
drop table if exists sms_coupon_spu_relation;
drop table if exists sms_home_adv;
drop table if exists sms_home_subject;
drop table if exists sms_home_subject_spu;
drop table if exists sms_member_price;
drop table if exists sms_seckill_promotion;
drop table if exists sms_seckill_session;
drop table if exists sms_seckill_sku_notice;
drop table if exists sms_seckill_sku_relation;
drop table if exists sms_sku_bounds;
drop table if exists sms_sku_full_reduction;
drop table if exists sms_sku_ladder;
drop table if exists sms_spu_bounds;
/*==============================================================*/
/* Table: sms_category_bounds */
/*==============================================================*/
create table sms_category_bounds
(
id bigint not null auto_increment comment 'id',
category_id bigint,
grow_bounds decimal(18,4) comment '成长积分',
buy_bounds decimal(18,4) comment '购物积分',
work tinyint(1) comment '优惠生效情况[1111(四个状态位,从右到左);0 - 无优惠,成长积分是否赠送;1 - 无优惠,购物积分是否赠送;2 - 有优惠,成长积分是否赠送;3 - 有优惠,购物积分是否赠送【状态位0:不赠送,1:赠送】]',
primary key (id)
);
alter table sms_category_bounds comment '商品分类积分设置';
/*==============================================================*/
/* Table: sms_coupon */
/*==============================================================*/
create table sms_coupon
(
id bigint not null auto_increment comment 'id',
coupon_type tinyint(1) comment '优惠卷类型[0->全场赠券;1->会员赠券;2->购物赠券;3->注册赠券]',
coupon_img varchar(2000) comment '优惠券图片',
coupon_name varchar(100) comment '优惠卷名字',
num int comment '数量',
amount decimal(18,4) comment '金额',
per_limit int comment '每人限领张数',
min_point decimal(18,4) comment '使用门槛',
start_time datetime comment '开始时间',
end_time datetime comment '结束时间',
use_type tinyint(1) comment '使用类型[0->全场通用;1->指定分类;2->指定商品]',
note varchar(200) comment '备注',
publish_count int(11) comment '发行数量',
use_count int(11) comment '已使用数量',
receive_count int(11) comment '领取数量',
enable_start_time datetime comment '可以领取的开始日期',
enable_end_time datetime comment '可以领取的结束日期',
code varchar(64) comment '优惠码',
member_level tinyint(1) comment '可以领取的会员等级[0->不限等级,其他-对应等级]',
publish tinyint(1) comment '发布状态[0-未发布,1-已发布]',
primary key (id)
);
alter table sms_coupon comment '优惠券信息';
/*==============================================================*/
/* Table: sms_coupon_history */
/*==============================================================*/
create table sms_coupon_history
(
id bigint not null auto_increment comment 'id',
coupon_id bigint comment '优惠券id',
member_id bigint comment '会员id',
member_nick_name varchar(64) comment '会员名字',
get_type tinyint(1) comment '获取方式[0->后台赠送;1->主动领取]',
create_time datetime comment '创建时间',
use_type tinyint(1) comment '使用状态[0->未使用;1->已使用;2->已过期]',
use_time datetime comment '使用时间',
order_id bigint comment '订单id',
order_sn bigint comment '订单号',
primary key (id)
);
alter table sms_coupon_history comment '优惠券领取历史记录';
/*==============================================================*/
/* Table: sms_coupon_spu_category_relation */
/*==============================================================*/
create table sms_coupon_spu_category_relation
(
id bigint not null auto_increment comment 'id',
coupon_id bigint comment '优惠券id',
category_id bigint comment '产品分类id',
category_name varchar(64) comment '产品分类名称',
primary key (id)
);
alter table sms_coupon_spu_category_relation comment '优惠券分类关联';
/*==============================================================*/
/* Table: sms_coupon_spu_relation */
/*==============================================================*/
create table sms_coupon_spu_relation
(
id bigint not null auto_increment comment 'id',
coupon_id bigint comment '优惠券id',
spu_id bigint comment 'spu_id',
spu_name varchar(255) comment 'spu_name',
primary key (id)
);
alter table sms_coupon_spu_relation comment '优惠券与产品关联';
/*==============================================================*/
/* Table: sms_home_adv */
/*==============================================================*/
create table sms_home_adv
(
id bigint not null auto_increment comment 'id',
name varchar(100) comment '名字',
pic varchar(500) comment '图片地址',
start_time datetime comment '开始时间',
end_time datetime comment '结束时间',
status tinyint(1) comment '状态',
click_count int comment '点击数',
url varchar(500) comment '广告详情连接地址',
note varchar(500) comment '备注',
sort int comment '排序',
publisher_id bigint comment '发布者',
auth_id bigint comment '审核者',
primary key (id)
);
alter table sms_home_adv comment '首页轮播广告';
/*==============================================================*/
/* Table: sms_home_subject */
/*==============================================================*/
create table sms_home_subject
(
id bigint not null auto_increment comment 'id',
name varchar(200) comment '专题名字',
title varchar(255) comment '专题标题',
sub_title varchar(255) comment '专题副标题',
status tinyint(1) comment '显示状态',
url varchar(500) comment '详情连接',
sort int comment '排序',
img varchar(500) comment '专题图片地址',
primary key (id)
);
alter table sms_home_subject comment '首页专题表【jd首页下面很多专题,每个专题链接新的页面,展示专题商品信息】';
/*==============================================================*/
/* Table: sms_home_subject_spu */
/*==============================================================*/
create table sms_home_subject_spu
(
id bigint not null auto_increment comment 'id',
name varchar(200) comment '专题名字',
subject_id bigint comment '专题id',
spu_id bigint comment 'spu_id',
sort int comment '
尚硅谷的商城sql语句CREATTE TABLE
需积分: 0 170 浏览量
更新于2022-09-03
收藏 10KB RAR 举报
在IT行业中,数据库管理是至关重要的,特别是在电子商务领域,如"尚硅谷的商城"这样的平台。MySQL是一种广泛使用的开源关系型数据库管理系统,它在处理大量数据时提供了高效、可靠和灵活的解决方案。在这个场景中,"CREATTE TABLE"是SQL(结构化查询语言)中的一个关键命令,用于在数据库中创建新的表格。下面我们将深入探讨这个知识点及其在实际应用中的重要性。
了解SQL的基本概念是非常必要的。SQL是用于管理和操作关系数据库的标准语言,包括数据的增删改查(CRUD)操作。在MySQL中,`CREATE TABLE`语句用于定义表格的结构,包括字段名、数据类型、约束条件等,这为存储和组织商城的各种信息提供了框架。
例如,在创建"尚硅谷的商城"的订单表时,我们可能需要以下字段:
1. `order_id`:订单ID,通常设置为主键,确保每个订单的唯一性,数据类型可以是`INT`。
2. `user_id`:用户ID,关联商城的用户,可以是`INT`类型。
3. `product_id`:商品ID,表示订单中的具体商品,也是`INT`类型。
4. `quantity`:购买数量,用`INT`或`DECIMAL`表示。
5. `price`:商品单价,通常使用`DECIMAL`以处理货币值。
6. `order_date`:订单日期,可以使用`DATE`或`DATETIME`类型。
7. `status`:订单状态,可能包含'待支付'、'已支付'、'已发货'等,可以使用`ENUM`或`VARCHAR`定义。
创建这样的订单表的SQL语句可能如下:
```sql
CREATE TABLE orders (
order_id INT PRIMARY KEY,
user_id INT,
product_id INT,
quantity INT,
price DECIMAL(10, 2),
order_date DATETIME,
status ENUM('待支付', '已支付', '已发货')
);
```
在这个例子中,`INT`用于整数,`DECIMAL(10, 2)`用于精确的小数,`DATETIME`用于日期和时间,`ENUM`用于限制字段只能取预定义的值。`PRIMARY KEY`是约束条件,确保`order_id`字段的唯一性。
在实际的"尚硅谷的商城"项目中,`gulimallsql`这个压缩包可能包含了各种与商城相关的数据库脚本,如商品表、用户表、分类表等。这些脚本会详细定义每个表格的结构,并且可能还包含了初始化数据,以便快速搭建数据库环境。
在开发和维护电商系统的过程中,`CREATE TABLE`语句的应用并不止于此。随着业务需求的变化,可能需要修改已有表格的结构,添加新字段或删除旧字段,这时就需要使用`ALTER TABLE`语句。此外,为了保证数据的一致性和完整性,还需要使用各种约束,如外键约束(FOREIGN KEY)、唯一性约束(UNIQUE)等。
理解和熟练运用SQL中的`CREATE TABLE`命令是开发和管理数据库的基础。在"尚硅谷的商城"这样的电商平台上,正确设计和实现数据库架构对于优化数据存储、提高查询效率、保障系统稳定性都起着关键作用。通过学习和实践,开发者可以构建出高效、易维护的数据库解决方案。

认真学java的秃头小白
- 粉丝: 8
最新资源
- 大数据时代思想政治教育模式的创新选择.docx
- 企业会计信息化审计的常见问题及对策.docx
- step7编程实例.ppt
- 文档模版--数据库设计说明书.doc
- 国家信息化(CEAC)试题集典型企业网络设计方案.doc
- 技工院校计算机教学中模块化的应用实践探微.docx
- 《大数据时代下的数据挖掘》试题及复习资料.doc
- 用现代教育技术促进中职计算机教学改革.docx
- 电子信息工程中自动化技术发展策略研究.docx
- 单片机数码录音与播放系统课程方案设计.doc
- 大数据在图书馆管理与服务中的运用.docx
- 机械手实施方案说明书制造自动化.doc
- 用友软件招聘面试技巧.ppt
- 电子与通信工程硕士培养实施方案全日制.doc
- 利用数据采集器定量探究钢铁腐蚀东北育才庄严.ppt
- 自动化控制计算机系统中的常见干扰及处理措施.docx