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 TransferSource Server         : demo
Source Server Version : 50622
Source Host           : localhost:3306
Source Database       : easyshoppingTarget Server Type    : MYSQL
Target Server Version : 50622
File Encoding         : 65001Date: 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表相关推荐

  1. mysql创建数据表列子,MySQL 创建数据库及简单增删改查

    MySQL 创建数据库及简单增删改查 我们可以在登陆 MySQL 服务后,使用 create 命令创建数据库,语法如下: CREATE DATABASE 数据库名; 登入: Enter passwor ...

  2. 0基础能学mysql数据库吗_mysql学习入门:零基础如何使用mysql创建数据库表?

    零基础如何自学Mysql创建数据库,是Mysql学习者必经之路,Mysql是受欢迎的关系数据库管理系统,WEB应用方面MySQL是很好的RDBMS应用软件之一.如何使用Mysql创建数据库表,打开My ...

  3. PHP教程 数据库和MySQL_PHP教程 - MySQL 创建数据库和表

    PHP MySQL 创建数据库和表 数据库存有一个或多个表. 创建数据库 CREATE DATABASE 语句用于在 MySQL 中创建数据库. 语法 CREATE DATABASE database ...

  4. MySQL创建数据库、创建数据表

    MySQL创建数据库.创建数据表 创建 MySQL 数据库时指定字符集和校对规则 mysql> CREATE DATABASE IF NOT EXISTS test_db_char DEFAUL ...

  5. 用MySQL创建数据库和数据库表(linux终端操作)

    用MySQL创建数据库和数据库表 http://tech.ccidnet.com/art/1105/20041104/173233_1.html 1.使用SHOW语句找出在服务器上当前存在什么数据库: ...

  6. 【mysql创建数据库以及表添加内容】

    mysql创建数据库以及表添加内容 第一步 先打开cmd 第二步 输入mysql -u root -p,然后就进入mysql 第三步 创建数据库 create database [数据库名],这里我用 ...

  7. MySQL创建数据库表student

    MySQL创建数据库表student 1,创建数据库 create database mydb: 2,查看所有数据库 show databases; 3,使用数据库 use mydb; 4,创建数据库 ...

  8. Mysql创建数据库表,查看表结构,查看表中数据,查看建表语句

    Mysql创建数据库表,查看表结构,查看表中数据,查看建表语句 1.创建数据库表 create table t_student( 表属性以,隔开 最后一行不用,): 2.查看表结构 desc t_st ...

  9. mysql 创建数据库 添加表

    mysql 创建数据库 添加表 -- 作业 -- 创建数据库 create database mydb character set utf8; -- 查询所有数据库 show DATABASES; - ...

  10. 用php创建数据库代码,php创建数据库_PHP MySQL 创建数据库与表示例

    摘要 腾兴网为您分享:PHP MySQL 创建数据库与表示例,掌上新华,携程,小牛,苏宁易购等软件知识,以及死神觉醒ios,花视频,s3云存储,华为谷歌器,学成网,cf掌上,互刷天下,抖音批量,润乾报 ...

最新文章

  1. 皮一皮:女友在意的点....是包子!
  2. SpringMVC4集成ehcache
  3. 图论—割点zcmu2095
  4. 黑马程序员-10 IO流2 File,properties,合并流,对象持久化,管道流,RandomAccessFile...
  5. 实例代码详解 bind(),One(),Live()
  6. wordpress 迁移网站更改域名解决图片无法显示
  7. python中的t操作_Python: s[i:j:k] = t 实现的是什么操作啊?
  8. 【Excel】如何用SUMIF实现SUMIFS的功能
  9. Windows平台手动卸载Oracle Server【完整+干净】
  10. appium操作多台手机_Appium常见问题解答
  11. 【已解决】华为手机USB调试和监控ADB安装应用的选项变成了灰色如何解决 | 华为荣耀9手机USB调试和监控ADB安装应用选项变成了灰色怎么办
  12. JavaScript prototype原型实现继承
  13. Android 给WebView设置UA
  14. 鸿蒙系统学习系列 | 上手HarmonyOS十大必看指南!
  15. 一键式统计6.0通透
  16. 产品经理的六大工作职责
  17. webservice接口和http接口(API接口)的区别
  18. 玩转B2B平台的商业模式你选对了吗?
  19. niagara框架中串口的打开方式
  20. 解决word中无法粘贴问题(Ctrl+V失灵问题)

热门文章

  1. R语言基于visreg 包COX回归和连续变量交互效应(交互作用)的可视化分析
  2. win7 共享计算机 网络密码怎么设置,win7局域网共享设置密码 win7局域网如何设置密码【详细步骤】...
  3. python编程语言创始人-涨姿势!10位编程语言创始人,你都知道是谁吗?
  4. 美通企业日报 | 英特尔20亿美元收购AI芯片制造商;嘉吉投资扩建河北嘉好粮油...
  5. word页码上加横线word删除单页页眉
  6. 浅层砂过滤器(浅层介质过滤器)介绍及现场案例反馈图(多图)
  7. 对java.lang.UnsupportedOperationException 异常的分析
  8. PAT Basic 1055
  9. oracle 同义词循环连,Oracle出现ORA-01775:同义词的循环链问题
  10. 流程框图-各方框含义