MySQL创建数据库 easyShopping,包括area表、goods表、customer表、orders表、ordersdetall表、test表
MySQL创建数据库 easyShopping,包括area表、goods表、customer表、orders表、ordersdetall表、test表
商品表表结构:
|
字段名 |
说 明 |
类 型 |
长 度 |
约 束 |
|
googsID |
商品编号 |
int |
— |
主键、自动增长 |
|
goodsCode |
商品编码 |
varchar |
20 |
非空 |
|
goodsName |
商品名 |
varchar |
50 |
非空 |
|
category |
商品种类 |
varchar |
20 |
— |
|
unitPrice |
单价 |
decimal(8,2) |
— |
— |
create table goods( --商品表
goodsID int primary key auto_increment,
goodsCode varchar(20) unique not null,
goodsName varchar(50) not null,
category varchar(20) default null,
unitPrice decimal(8,2) default null,
areaID int default null,
saleCount int default null
);
顾客表表结构:
|
字段名 |
说 明 |
类 型 |
长 度 |
约 束 |
|
customerID |
客户编号 |
int |
— |
主键、自动增长 |
|
loginID |
登录 ID |
varchar |
20 |
非空 |
|
pwd |
密码 |
varchar |
10 |
非空 |
|
cName |
客户姓名 |
varchar |
20 |
非空 |
|
address |
客户地址 |
varchar |
50 |
— |
|
phone |
客户电话 |
varchar |
20 |
— |
create table customer( --客户表
customerID int primary key auto_increment,
loginID varchar(20) unique not null,
pwd varchar(10) not null,
cName varchar(20) not null,
city varchar(20) default null,
address varchar(50) default null,
phone varchar(20) default null
);
订单表表结构:
|
字段名 |
说 明 |
类 型 |
长 度 |
约 束 |
|
ordersID |
订单编号 |
int |
— |
主键、自动增长 |
|
ordersDate |
下单日期 |
date |
— |
非空 |
|
deliveryDate |
送达日期 |
date |
— |
— |
|
amount |
订单金额 |
decimal(10,2) |
— |
— |
|
customerID |
客户编号 |
int |
— |
外键,参照 customers 表 |
完整语法:
/*
Navicat MySQL Data Transfer
Source Server : demo
Source Server Version : 50622
Source Host : localhost:3306
Source Database : easyshopping
Target Server Type : MYSQL
Target Server Version : 50622
File Encoding : 65001
Date: 2020-04-01 10:11:51
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for `area`
-- ----------------------------
DROP TABLE IF EXISTS `area`;
CREATE TABLE `area` (
`areaID` int(11) NOT NULL AUTO_INCREMENT,
`areaName` varchar(20) DEFAULT NULL,
PRIMARY KEY (`areaID`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of area
-- ----------------------------
INSERT INTO `area` VALUES ('1', '北京');
INSERT INTO `area` VALUES ('2', '上海');
INSERT INTO `area` VALUES ('3', '深圳');
INSERT INTO `area` VALUES ('4', '广州');
INSERT INTO `area` VALUES ('5', '南京');
-- ----------------------------
-- Table structure for `customer`
-- ----------------------------
DROP TABLE IF EXISTS `customer`;
CREATE TABLE `customer` (
`customerID` int(11) NOT NULL AUTO_INCREMENT,
`loginID` varchar(20) NOT NULL,
`pwd` varchar(10) NOT NULL,
`cName` varchar(20) NOT NULL,
`city` varchar(20) DEFAULT NULL,
`address` varchar(50) DEFAULT NULL,
`phone` varchar(20) DEFAULT NULL,
PRIMARY KEY (`customerID`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of customer
-- ----------------------------
INSERT INTO `customer` VALUES ('2', 'abc222', '222', '王传华', '北京', '北京市东城区香河园路16 号', '01062111234');
INSERT INTO `customer` VALUES ('3', 'abc333', '333', '张晓静', '北京', '北京市东城区东直门大街2号', '13501229678');
INSERT INTO `customer` VALUES ('4', 'abc444', '444', '张洪涛', '上海', '上海市徐汇区漕溪路126号', '13818929999');
INSERT INTO `customer` VALUES ('5', 'abc555', '555', '王勇强', '上海', '上海市杨浦区大连路1548', '13671648888');
INSERT INTO `customer` VALUES ('7', 'abc777', '777', '刘亚其', '武汉', '武汉市江岸区洞庭街67', '18674060972');
INSERT INTO `customer` VALUES ('8', 'abc888', '888', '张兆', '武汉', '武汉市洪山区关山一路45号', '18672791254');
-- ----------------------------
-- Table structure for `goods`
-- ----------------------------
DROP TABLE IF EXISTS `goods`;
CREATE TABLE `goods` (
`goodsID` int(11) NOT NULL AUTO_INCREMENT,
`goodsCode` varchar(20) DEFAULT NULL,
`goodsName` varchar(50) DEFAULT NULL,
`category` varchar(20) DEFAULT NULL,
`unitPrice` decimal(8,2) DEFAULT NULL,
`areaID` int(11) DEFAULT NULL,
`saleCount` int(11) DEFAULT NULL,
PRIMARY KEY (`goodsID`),
UNIQUE KEY `goodsName` (`goodsName`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of goods
-- ----------------------------
INSERT INTO `goods` VALUES ('1', '01001', '从心选择的智慧(李开复)', '书籍', '18.50', '1', '3');
INSERT INTO `goods` VALUES ('2', '01002', 'Java面向对象编程(孙卫琴)', '书籍', '52.60', '2', '6');
INSERT INTO `goods` VALUES ('3', '01003', '漫谈中国文化(南怀瑾)', '书籍', '13.00', '3', '13');
INSERT INTO `goods` VALUES ('4', '02001', '艾美特FSW65R-5落地风扇', '生活电器', '199.00', '2', '9');
INSERT INTO `goods` VALUES ('5', '02002', '飞利浦HD3035/05电饭煲', '生活电器', '299.00', '4', '3');
INSERT INTO `goods` VALUES ('6', '02003', '美的FD302电饭煲', '生活电器', '248.00', '2', '7');
INSERT INTO `goods` VALUES ('7', '02004', '格力KYT-2503台式转页扇', '生活电器', '88.00', '4', '8');
INSERT INTO `goods` VALUES ('8', '03001', '尤尼克斯Yonex羽毛球拍', '体育用品', '209.00', '1', '9');
INSERT INTO `goods` VALUES ('9', '03002', 'NIKE篮球BB0361-823', '体育用品', '89.00', '1', '3');
INSERT INTO `goods` VALUES ('10', '03003', '火车头Train5号PU足球TS5011', '体育用品', '135.00', '3', '6');
-- ----------------------------
-- Table structure for `orders`
-- ----------------------------
DROP TABLE IF EXISTS `orders`;
CREATE TABLE `orders` (
`ordersID` int(11) NOT NULL AUTO_INCREMENT,
`ordersDate` date NOT NULL,
`deliveryDate` date DEFAULT NULL,
`amount` decimal(10,2) DEFAULT NULL,
`customerID` int(11) DEFAULT NULL,
PRIMARY KEY (`ordersID`),
KEY `fk_orders_customer` (`customerID`),
CONSTRAINT `fk_orders_customer` FOREIGN KEY (`customerID`) REFERENCES `customer` (`customerID`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=latin1;
-- ----------------------------
-- Records of orders
-- ----------------------------
INSERT INTO `orders` VALUES ('1', '2015-04-10', '2015-04-12', null, '2');
INSERT INTO `orders` VALUES ('2', '2015-05-16', '2015-05-19', null, '5');
INSERT INTO `orders` VALUES ('3', '2015-03-18', '2015-03-19', null, null);
INSERT INTO `orders` VALUES ('4', '2015-04-12', '2015-04-14', null, '3');
INSERT INTO `orders` VALUES ('5', '2015-04-10', '2015-04-12', null, '4');
INSERT INTO `orders` VALUES ('6', '2015-05-16', '2015-05-18', null, '8');
INSERT INTO `orders` VALUES ('7', '2015-03-18', '2015-03-21', null, '7');
INSERT INTO `orders` VALUES ('8', '2015-06-19', '2015-06-20', null, null);
INSERT INTO `orders` VALUES ('9', '2015-04-12', '2015-04-13', '3126.50', '3');
INSERT INTO `orders` VALUES ('10', '2015-05-28', '2015-05-30', null, '5');
INSERT INTO `orders` VALUES ('11', '2015-03-08', '2015-03-09', null, '2');
INSERT INTO `orders` VALUES ('12', '2015-03-08', '2015-03-10', null, '4');
INSERT INTO `orders` VALUES ('13', '2015-03-08', '2015-03-11', null, '5');
INSERT INTO `orders` VALUES ('14', '2015-03-18', '2015-03-20', null, null);
INSERT INTO `orders` VALUES ('15', '2015-04-12', '2015-04-13', '1252.50', '4');
-- ----------------------------
-- Table structure for `ordersdetail`
-- ----------------------------
DROP TABLE IF EXISTS `ordersdetail`;
CREATE TABLE `ordersdetail` (
`ordersID` int(11) NOT NULL,
`goodsID` int(11) NOT NULL,
`quantity` int(11) DEFAULT NULL,
`money` decimal(10,2) DEFAULT NULL,
PRIMARY KEY (`ordersID`,`goodsID`),
KEY `fk3` (`goodsID`),
CONSTRAINT `fk2` FOREIGN KEY (`ordersID`) REFERENCES `orders` (`ordersID`),
CONSTRAINT `fk3` FOREIGN KEY (`goodsID`) REFERENCES `goods` (`goodsID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- ----------------------------
-- Records of ordersdetail
-- ----------------------------
INSERT INTO `ordersdetail` VALUES ('1', '2', '2', null);
INSERT INTO `ordersdetail` VALUES ('1', '3', '3', null);
INSERT INTO `ordersdetail` VALUES ('2', '3', '1', null);
INSERT INTO `ordersdetail` VALUES ('2', '4', '2', null);
INSERT INTO `ordersdetail` VALUES ('3', '6', '2', null);
INSERT INTO `ordersdetail` VALUES ('3', '8', '3', null);
INSERT INTO `ordersdetail` VALUES ('4', '5', '2', null);
INSERT INTO `ordersdetail` VALUES ('4', '7', '3', null);
INSERT INTO `ordersdetail` VALUES ('5', '1', '3', null);
INSERT INTO `ordersdetail` VALUES ('5', '3', '2', null);
INSERT INTO `ordersdetail` VALUES ('6', '2', '1', null);
INSERT INTO `ordersdetail` VALUES ('6', '3', '2', null);
INSERT INTO `ordersdetail` VALUES ('6', '4', '3', null);
INSERT INTO `ordersdetail` VALUES ('7', '5', '1', null);
INSERT INTO `ordersdetail` VALUES ('7', '6', '1', null);
INSERT INTO `ordersdetail` VALUES ('8', '3', '3', null);
INSERT INTO `ordersdetail` VALUES ('8', '4', '2', null);
INSERT INTO `ordersdetail` VALUES ('9', '2', '3', null);
INSERT INTO `ordersdetail` VALUES ('10', '4', '2', null);
INSERT INTO `ordersdetail` VALUES ('10', '7', '3', null);
INSERT INTO `ordersdetail` VALUES ('11', '9', '2', null);
INSERT INTO `ordersdetail` VALUES ('11', '10', '3', null);
INSERT INTO `ordersdetail` VALUES ('12', '6', '3', null);
INSERT INTO `ordersdetail` VALUES ('12', '8', '1', null);
INSERT INTO `ordersdetail` VALUES ('13', '8', '3', null);
INSERT INTO `ordersdetail` VALUES ('13', '9', '1', null);
INSERT INTO `ordersdetail` VALUES ('14', '3', '2', null);
INSERT INTO `ordersdetail` VALUES ('14', '8', '2', null);
INSERT INTO `ordersdetail` VALUES ('15', '6', '1', null);
INSERT INTO `ordersdetail` VALUES ('15', '7', '2', null);
INSERT INTO `ordersdetail` VALUES ('15', '10', '3', null);
-- ----------------------------
-- Table structure for `test`
-- ----------------------------
DROP TABLE IF EXISTS `test`;
CREATE TABLE `test` (
`name` varchar(255) DEFAULT NULL,
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of test
-- ----------------------------
INSERT INTO `test` VALUES ('zhang');
MySQL创建数据库 easyShopping,包括area表、goods表、customer表、orders表、ordersdetall表、test表的更多相关文章
- PHP MySQL 创建数据库
PHP MySQL 创建数据库 数据库存有一个或多个表. 你需要 CREATE 权限来创建或删除 MySQL 数据库. 使用 MySQLi 和 PDO 创建 MySQL 数据库 CREATE DATA ...
- MYSQL创建数据库时候直接指定编码和排序规则
安装我 在网上搜索的结果执行 代码: sudo gedit /etc/mysql/my.cnf 设置了默认编码为 UTF8 代码: [client]port = 3306sock ...
- Python MySQL 创建数据库
章节 Python MySQL 入门 Python MySQL 创建数据库 Python MySQL 创建表 Python MySQL 插入表 Python MySQL Select Python M ...
- mysql创建数据库
mysql创建数据库 创建utf8编码的数据库 CREATE DATABASE IF NOT EXISTS my_db default character set utf8 COLLATE utf8_ ...
- mysql创建数据库指定编码uft8
mysql创建数据库指定编码uft8 CREATE DATABASE IF NOT EXISTS my_db default character set utf8 COLLATE utf8_gener ...
- MySQL 创建数据库
MySQL 创建数据库 使用 mysqladmin 创建数据库 使用普通用户,你可能需要特定的权限来创建或者删除 MySQL 数据库. 所以我们这边使用root用户登录,root用户拥有最高权限,可以 ...
- 五、MySQL 创建数据库
MySQL 创建数据库 我们可以在登陆 MySQL 服务后,使用 create 命令创建数据库,语法如下: CREATE DATABASE 数据库名; 以下命令简单的演示了创建数据库的过程,数据名为 ...
- mysql创建数据库指定字符集和校对规则
mysql创建数据库的语法格式: CREATE DATABASE [IF NOT EXISTS] <数据库名> [[DEFAULT] CHARACTER SET <字符集名>] ...
- mysql创建数据库用户
连接mysql cmd--> mysql -hlocalhost -uroot -pmypassword 退出mysql mysql> quit 也可用exit或者 \q ======== ...
随机推荐
- Linux定时任务crontable简介
Linux下定时执行任务的方法:Linux之crond 服务介绍:https://www.cnblogs.com/liang-io/p/9596294.html http://www.mamicode ...
- java代码定时备份mysql数据库及注意事项——基于 springboot
源码地址: https://gitee.com/kevin9401/BackUpDataBase git 拉取: https://gitee.com/kevin9401/BackUpDataBase. ...
- 删除数据库时报错 ERROR 1010 (HY000): Error dropping database (can't rmdir './cart', errno: 39)
这是因为在数据目录下有表相关的数据(不是表),此时应该进入存放表的目录下删除与表相关的数据,一般数据存放目录默认为/var/lib/mysql,cd到目录下 执行命令:cd /var/lib/mysq ...
- Spring Boot中使用Redis
一.定义工程 创建一个spring boot模块 二.修改pom文件 在pom文件中添加Spring Boot与Redis整合依赖 <dependencies> <!--spring ...
- mybatis分页插件PageHelper源码浅析
PageHelper 是Mybaties中的一个分页插件.其maven坐标 <!-- https://mvnrepository.com/artifact/com.github.pagehelp ...
- 【力扣】973. 最接近原点的 K 个点
我们有一个由平面上的点组成的列表 points.需要从中找出 K 个距离原点 (0, 0) 最近的点. (这里,平面上两点之间的距离是欧几里德距离.) 你可以按任何顺序返回答案.除了点坐标的顺序之外, ...
- shell脚本 检查mysql节点数据一致性
一.简介 源码地址 日期:2018/4/12 介绍:参考pt checksum思想改写,可以定制化的检查随意两个mysql节点的数据一致性. 功能: 检查随意两个几点的数据一致性 支持并发检查,基于库 ...
- java中注释、关键字、标识符,数据类型(上)
一.java中的注释(有3种) 注释:是给写代码的人看的,注释不会被执行 单行注释:用符号"//"实现 多行注释:用"/* */ " 实现 javaDoc(文档 ...
- 解决电脑连接 iPhone 热点没有 IPv6地址的问题
问题描述: 初入 iPhone ,电脑使用 ios 共享的热点无法连接 IPv6 地址.但是,直接在 iPhone 上面打开 https://www.test-ipv6.com/ 完美支持 IPv6 ...
- 为什么没有APS排产的MES是没有灵魂的?
ERP系统在于对整个企业与集团企业间的全面管控,APS系统是生产规划及排程系统,MES系统重点在于车间现场的管理,下面用最简单方式讲讲ERP系统.APS系统和MES系统之间的区别与联系. 没有APS计 ...