最近在复习SQL语句,看的是MySQL必知必会这本书,但是发现附录中只有表设计,没有表的具体数据。所以在学习相应的语句中体验不是很好,去网上查了数据库的内容,自己慢慢导入到了数据库中。把表放出来作为参照,SQL脚本语句放在最后,可以直接导到自己的数据库。

customer表

orderitems表

orders表

productnotes表

products表

vendors表

数据库SQL脚本语句

  1. /*
  2. Navicat Premium Data Transfer
  3. Source Server : localhost_3306
  4. Source Server Type : MySQL
  5. Source Server Version : 50612
  6. Source Host : localhost:3306
  7. Source Schema : zlx_mysql
  8. Target Server Type : MySQL
  9. Target Server Version : 50612
  10. File Encoding : 65001
  11. Date: 19/12/2019 23:03:46
  12. */
  13. SET NAMES utf8mb4;
  14. SET FOREIGN_KEY_CHECKS = 0;
  15. -- ----------------------------
  16. -- Table structure for customers
  17. -- ----------------------------
  18. DROP TABLE IF EXISTS `customers`;
  19. CREATE TABLE `customers` (
  20. `cust_id` int(11) NOT NULL AUTO_INCREMENT,
  21. `cust_name` char(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL,
  22. `cust_address` char(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
  23. `cust_city` char(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
  24. `cust_state` char(5) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
  25. `cust_zip` char(10) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
  26. `cust_country` char(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
  27. `cust_contact` char(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
  28. `cust_email` char(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
  29. PRIMARY KEY (`cust_id`) USING BTREE
  30. ) ENGINE = InnoDB AUTO_INCREMENT = 10006 CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Compact;
  31. -- ----------------------------
  32. -- Records of customers
  33. -- ----------------------------
  34. INSERT INTO `customers` VALUES (10001, 'Coyote Inc.', '200 Maple Lane', 'Detroit', 'MI', '44444', 'USA', 'Y Lee', 'ylee@coyote.com');
  35. INSERT INTO `customers` VALUES (10002, 'Mouse House', '333 Fromage Lane', 'Columbus', 'OH', '43333', 'USA', 'Jerry Mouse', NULL);
  36. INSERT INTO `customers` VALUES (10003, 'Wascals', '1 Sunny Place', 'Muncie', 'IN', '42222', 'USA', 'Jim Jones', 'rabbit@wascally.com');
  37. INSERT INTO `customers` VALUES (10004, 'Yosemite Place', '829 Riverside Drive', 'Phoenix', 'AZ', '88888', 'USA', 'Y Sam', 'sam@yosemite.com');
  38. INSERT INTO `customers` VALUES (10005, 'E Fudd', '4545 53rd Street', 'Chicago', 'IL', '54545', 'USA', 'E Fudd', NULL);
  39. -- ----------------------------
  40. -- Table structure for orderitems
  41. -- ----------------------------
  42. DROP TABLE IF EXISTS `orderitems`;
  43. CREATE TABLE `orderitems` (
  44. `order_num` int(11) NOT NULL,
  45. `order_item` int(11) NOT NULL,
  46. `prod_id` char(10) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL,
  47. `quantity` int(11) NOT NULL,
  48. `item_price` decimal(8, 2) NOT NULL,
  49. PRIMARY KEY (`order_num`, `order_item`) USING BTREE,
  50. INDEX `fk_orderitems_products`(`prod_id`) USING BTREE,
  51. CONSTRAINT `fk_orderitems_products` FOREIGN KEY (`prod_id`) REFERENCES `products` (`prod_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  52. CONSTRAINT `fk_orderitems_orders` FOREIGN KEY (`order_num`) REFERENCES `orders` (`order_num`) ON DELETE RESTRICT ON UPDATE RESTRICT
  53. ) ENGINE = InnoDB CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Compact;
  54. -- ----------------------------
  55. -- Records of orderitems
  56. -- ----------------------------
  57. INSERT INTO `orderitems` VALUES (20005, 1, 'ANV01', 10, 5.99);
  58. INSERT INTO `orderitems` VALUES (20005, 2, 'ANV02', 3, 9.99);
  59. INSERT INTO `orderitems` VALUES (20005, 3, 'TNT2', 5, 10.00);
  60. INSERT INTO `orderitems` VALUES (20005, 4, 'FB', 1, 10.00);
  61. INSERT INTO `orderitems` VALUES (20006, 1, 'JP2000', 1, 55.00);
  62. INSERT INTO `orderitems` VALUES (20007, 1, 'TNT2', 100, 10.00);
  63. INSERT INTO `orderitems` VALUES (20008, 1, 'FC', 50, 2.50);
  64. INSERT INTO `orderitems` VALUES (20009, 1, 'FB', 1, 10.00);
  65. INSERT INTO `orderitems` VALUES (20009, 2, 'OL1', 1, 8.99);
  66. INSERT INTO `orderitems` VALUES (20009, 3, 'SLING', 1, 4.49);
  67. INSERT INTO `orderitems` VALUES (20009, 4, 'ANV03', 1, 14.99);
  68. -- ----------------------------
  69. -- Table structure for orders
  70. -- ----------------------------
  71. DROP TABLE IF EXISTS `orders`;
  72. CREATE TABLE `orders` (
  73. `order_num` int(11) NOT NULL AUTO_INCREMENT,
  74. `order_date` datetime(0) NOT NULL,
  75. `cust_id` int(11) NOT NULL,
  76. PRIMARY KEY (`order_num`) USING BTREE,
  77. INDEX `fk_orders_customers`(`cust_id`) USING BTREE,
  78. CONSTRAINT `fk_orders_customers` FOREIGN KEY (`cust_id`) REFERENCES `customers` (`cust_id`) ON DELETE RESTRICT ON UPDATE RESTRICT
  79. ) ENGINE = InnoDB AUTO_INCREMENT = 20010 CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Compact;
  80. -- ----------------------------
  81. -- Records of orders
  82. -- ----------------------------
  83. INSERT INTO `orders` VALUES (20005, '2005-09-01 00:00:00', 10001);
  84. INSERT INTO `orders` VALUES (20006, '2005-09-12 00:00:00', 10003);
  85. INSERT INTO `orders` VALUES (20007, '2005-09-30 00:00:00', 10004);
  86. INSERT INTO `orders` VALUES (20008, '2005-10-03 00:00:00', 10005);
  87. INSERT INTO `orders` VALUES (20009, '2005-10-08 00:00:00', 10001);
  88. -- ----------------------------
  89. -- Table structure for productnotes
  90. -- ----------------------------
  91. DROP TABLE IF EXISTS `productnotes`;
  92. CREATE TABLE `productnotes` (
  93. `note_id` int(11) NOT NULL AUTO_INCREMENT,
  94. `prod_id` char(10) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL,
  95. `note_date` datetime(0) NOT NULL,
  96. `note_text` text CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL,
  97. PRIMARY KEY (`note_id`) USING BTREE,
  98. FULLTEXT INDEX `note_text`(`note_text`)
  99. ) ENGINE = MyISAM AUTO_INCREMENT = 115 CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Dynamic;
  100. -- ----------------------------
  101. -- Records of productnotes
  102. -- ----------------------------
  103. INSERT INTO `productnotes` VALUES (101, 'TNT2', '2005-08-17 00:00:00', 'Customer complaint:\r\nSticks not individually wrapped, too easy to mistakenly detonate all at once.\r\nRecommend individual wrapping.');
  104. INSERT INTO `productnotes` VALUES (102, 'OL1', '2005-08-18 00:00:00', 'Can shipped full, refills not available.\r\nNeed to order new can if refill needed.');
  105. INSERT INTO `productnotes` VALUES (103, 'SAFE', '2005-08-18 00:00:00', 'Safe is combination locked, combination not provided with safe.\r\nThis is rarely a problem as safes are typically blown up or dropped by customers.');
  106. INSERT INTO `productnotes` VALUES (104, 'FC', '2005-08-19 00:00:00', 'Quantity varies, sold by the sack load.\r\nAll guaranteed to be bright and orange, and suitable for use as rabbit bait.');
  107. INSERT INTO `productnotes` VALUES (105, 'TNT2', '2005-08-20 00:00:00', 'Included fuses are short and have been known to detonate too quickly for some customers.\r\nLonger fuses are available (item FU1) and should be recommended.');
  108. INSERT INTO `productnotes` VALUES (106, 'TNT2', '2005-08-22 00:00:00', 'Matches not included, recommend purchase of matches or detonator (item DTNTR).');
  109. INSERT INTO `productnotes` VALUES (107, 'SAFE', '2005-08-23 00:00:00', 'Please note that no returns will be accepted if safe opened using explosives.');
  110. INSERT INTO `productnotes` VALUES (108, 'ANV01', '2005-08-25 00:00:00', 'Multiple customer returns, anvils failing to drop fast enough or falling backwards on purchaser. Recommend that customer considers using heavier anvils.');
  111. INSERT INTO `productnotes` VALUES (109, 'ANV03', '2005-09-01 00:00:00', 'Item is extremely heavy. Designed for dropping, not recommended for use with slings, ropes, pulleys, or tightropes.');
  112. INSERT INTO `productnotes` VALUES (110, 'FC', '2005-09-01 00:00:00', 'Customer complaint: rabbit has been able to detect trap, food apparently less effective now.');
  113. INSERT INTO `productnotes` VALUES (111, 'SLING', '2005-09-02 00:00:00', 'Shipped unassembled, requires common tools (including oversized hammer).');
  114. INSERT INTO `productnotes` VALUES (112, 'SAFE', '2005-09-02 00:00:00', 'Customer complaint:\r\nCircular hole in safe floor can apparently be easily cut with handsaw.');
  115. INSERT INTO `productnotes` VALUES (113, 'ANV01', '2005-09-05 00:00:00', 'Customer complaint:\r\nNot heavy enough to generate flying stars around head of victim. If being purchased for dropping, recommend ANV02 or ANV03 instead.');
  116. INSERT INTO `productnotes` VALUES (114, 'SAFE', '2005-09-07 00:00:00', 'Call from individual trapped in safe plummeting to the ground, suggests an escape hatch be added.\r\nComment forwarded to vendor.');
  117. -- ----------------------------
  118. -- Table structure for products
  119. -- ----------------------------
  120. DROP TABLE IF EXISTS `products`;
  121. CREATE TABLE `products` (
  122. `prod_id` char(10) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL,
  123. `vend_id` int(11) NOT NULL,
  124. `prod_name` char(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL,
  125. `prod_price` decimal(8, 2) NOT NULL,
  126. `prod_desc` text CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL,
  127. PRIMARY KEY (`prod_id`) USING BTREE,
  128. INDEX `fk_products_vendors`(`vend_id`) USING BTREE,
  129. CONSTRAINT `fk_products_vendors` FOREIGN KEY (`vend_id`) REFERENCES `vendors` (`vend_id`) ON DELETE RESTRICT ON UPDATE RESTRICT
  130. ) ENGINE = InnoDB CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Compact;
  131. -- ----------------------------
  132. -- Records of products
  133. -- ----------------------------
  134. INSERT INTO `products` VALUES ('ANV01', 1001, '.5 ton anvil', 5.99, '.5 ton anvil, black, complete with handy hook');
  135. INSERT INTO `products` VALUES ('ANV02', 1001, '1 ton anvil', 9.99, '1 ton anvil, black, complete with handy hook and carrying case');
  136. INSERT INTO `products` VALUES ('ANV03', 1001, '2 ton anvil', 14.99, '2 ton anvil, black, complete with handy hook and carrying case');
  137. INSERT INTO `products` VALUES ('DTNTR', 1003, 'Detonator', 13.00, 'Detonator (plunger powered), fuses not included');
  138. INSERT INTO `products` VALUES ('FB', 1003, 'Bird seed', 10.00, 'Large bag (suitable for road runners)');
  139. INSERT INTO `products` VALUES ('FC', 1003, 'Carrots', 2.50, 'Carrots (rabbit hunting season only)');
  140. INSERT INTO `products` VALUES ('FU1', 1002, 'Fuses', 3.42, '1 dozen, extra long');
  141. INSERT INTO `products` VALUES ('JP1000', 1005, 'JetPack 1000', 35.00, 'JetPack 1000, intended for single use');
  142. INSERT INTO `products` VALUES ('JP2000', 1005, 'JetPack 2000', 55.00, 'JetPack 2000, multi-use');
  143. INSERT INTO `products` VALUES ('OL1', 1002, 'Oil can', 8.99, 'Oil can, red');
  144. INSERT INTO `products` VALUES ('SAFE', 1003, 'Safe', 50.00, 'Safe with combination lock');
  145. INSERT INTO `products` VALUES ('SLING', 1003, 'Sling', 4.49, 'Sling, one size fits all');
  146. INSERT INTO `products` VALUES ('TNT1', 1003, 'TNT (1 stick)', 2.50, 'TNT, red, single stick');
  147. INSERT INTO `products` VALUES ('TNT2', 1003, 'TNT (5 sticks)', 10.00, 'TNT, red, pack of 10 sticks');
  148. -- ----------------------------
  149. -- Table structure for vendors
  150. -- ----------------------------
  151. DROP TABLE IF EXISTS `vendors`;
  152. CREATE TABLE `vendors` (
  153. `vend_id` int(11) NOT NULL AUTO_INCREMENT,
  154. `vend_name` char(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL,
  155. `vend_address` char(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
  156. `vend_city` char(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
  157. `vend_state` char(5) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
  158. `vend_zip` char(10) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
  159. `vend_country` char(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
  160. PRIMARY KEY (`vend_id`) USING BTREE
  161. ) ENGINE = InnoDB AUTO_INCREMENT = 1007 CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Compact;
  162. -- ----------------------------
  163. -- Records of vendors
  164. -- ----------------------------
  165. INSERT INTO `vendors` VALUES (1001, 'Anvils R Us', '123 Main Street', 'Southfield', 'MI', '48075', 'USA');
  166. INSERT INTO `vendors` VALUES (1002, 'LT Supplies', '500 Park Street', 'Anytown', 'OH', '44333', 'USA');
  167. INSERT INTO `vendors` VALUES (1003, 'ACME', '555 High Street', 'Los Angeles', 'CA', '90046', 'USA');
  168. INSERT INTO `vendors` VALUES (1004, 'Furball Inc.', '1000 5th Avenue', 'New York', 'NY', '11111', 'USA');
  169. INSERT INTO `vendors` VALUES (1005, 'Jet Set', '42 Galaxy Road', 'London', NULL, 'N16 6PS', 'England');
  170. INSERT INTO `vendors` VALUES (1006, 'Jouets Et Ours', '1 Rue Amusement', 'Paris', NULL, '45678', 'France');
  171. SET FOREIGN_KEY_CHECKS = 1;

MySQL必知必会-官方数据库表及SQL脚本导入生成的更多相关文章

  1. 数据库备份及SQL脚本导入

    数据库备份及SQL脚本导入 数据导出 su - oracle exp 数据库用户名/数据库密码@ORCL file=20190905.dmp full=y SQL脚本导入 首先导入前查看Oracle用 ...

  2. 使用PD(PowerDesigner)图如何快速生成创建数据库表的SQL脚本

    打开PD软件: 1.新建概念模型(conceptual Data Model) File-->New Model-->Conceptual Data Mode 或者点击工作区,右键--&g ...

  3. 《MySQL必知必会》官方提供的数据库和表

    数据用于配合<MySQL必知必会>(MySQL Crash Course)这本书使用,配套SQL文件也可在Ben Forta网站下载. Ben Forta网址:http://forta.c ...

  4. 【SQL必知必会笔记(1)】数据库基础、SQL、MySQL8.0.16下数据库、表的创建及数据插入

    文章目录 1.数据库基础 1.1 数据库(database) 1.2 表(table) 1.3 列和数据类型 1.4 行 1.5 主键 2.什么是SQL 3.创建后续练习所需数据库.表(MySQL8. ...

  5. 《MySQL 必知必会》读书总结

    这是 <MySQL 必知必会> 的读书总结.也是自己整理的常用操作的参考手册. 使用 MySQL 连接到 MySQL shell>mysql -u root -p Enter pas ...

  6. 《MySQL必知必会》[01] 基本查询

    <MySQL必知必会>(点击查看详情) 1.写在前面的话 这本书是一本MySQL的经典入门书籍,小小的一本,也受到众多网友推荐.之前自己学习的时候是啃的清华大学出版社的计算机系列教材< ...

  7. mysql必知必会系列(一)

    mysql必知必会系列是本人在读<mysql必知必会>中的笔记,方便自己以后查看. MySQL. Oracle以及Microsoft SQL Server等数据库是基于客户机-服务器的数据 ...

  8. mysql必知必会

    春节放假没事,找了本电子书mysql必知必会敲了下.用的工具是有道笔记的markdown文档类型. 下面是根据大纲已经敲完的章节,可复制到有道笔记的查看,更美观. # 第一章 了解SQL## 什么是S ...

  9. 《MySQL必知必会》整理

    目录 第1章 了解数据库 1.1 数据库基础 1.1.1 什么是数据库 1.1.2 表 1.1.3 列和数据类型 1.1.4 行 1.1.5 主键 1.2 什么是SQL 第2章 MySQL简介 2.1 ...

随机推荐

  1. 让块元素在div中水平居中,并且垂直居中的五种方法

    在写代码前,先做下准备工作,写两个div,设置下div的大小,把小的div放在大的div里面.可以给小的div设置下颜色,方便观看. 方法一:写一个伪元素,将它设置为行内块元素,高度与父元素相同,写一 ...

  2. mysql定时任务(event事件)

    1.event事件 事件(event)是MySQL在相应的时刻调用的过程式数据库对象.一个事件可调用一次,也可周期性的启动,它由一个特定的线程来管理的,也就是所谓的“事件调度器” 事件和触发器类似,都 ...

  3. python2的编码问题小结

    对于python2,经常会遇到编码问题,在此小记一下. Python2默认的编码解码方式是ascii码,这点要牢记. windows系统默认是gbk编码的,可以使用chcp查看:936,那就是GBK简 ...

  4. FIddler+Proxifer工具对windows PC客户端进行抓包

    python的大火,带动了python爬虫. 爬虫就必定绕不开抓包. 目前最常见的就是网页抓包了,可以使用chrome进行,或者配合其他抓包软件 fiddler. 小程序有些兴起是,如跳一跳之类的,也 ...

  5. Android的系统框架的深入认识

    Android采用层次化系统架构,官方公布的标准架构如下图所示.Android由底层往上分为4个主要功能层,分别是linux内核层(Linux Kernel),系统运行时库层(Libraries和An ...

  6. H3C交换机DHCP基础配置案例 v7版本

    一.需求 要求在Switch A上配置DHCP服务器功能实现:• 为网络内的客户端动态分配 10.1.1.0/24 网段内的 IP 地址.租用有效期限. DNS 信息.网关地址等配置信息:• 根据 S ...

  7. 2019-11-26:密码学基础知识,csrf防御

    信息安全的基础是数学--->密码算法--->安全协议(ssl VPN)-->应用(证书 PKI)密码学入门密码编码学:研究加解密算法的学科密码分析学:研究破译密码算法的学科 加解密分 ...

  8. java中的基本数据类型转换

    Java 中的 8 种基本数据类型,以及它们的占内存的容量大小和表示的范围,如下图所示: 重新温故了下原始数据类型,现在来解释下它们之间的转换关系. 自动类型转换 自动类型转换是指:数字表示范围小的数 ...

  9. Centos 6.x Openssh 升级 7.7p1 版本

    OpenSSH 升级 目前在一家金融公司上班,正好赶上金融公司各种暴雷,本人心里慌慌的. 然后就是金融公司要进行的最低的三级等保评测,各种修改系统安全,密码强度.WAF.防火墙等各种. 评测公司对我司 ...

  10. [开源] 基于Layui组件封装的后台模版,HG-Layui-UI通用后台管理框架V1.0版

    HG框架简介 HG-Layui-UI框架,是基于layui最新版UI搭建的一套通用后台管理框架,借鉴了市面上各大主流框架风格,采用iframe标签页实现,保留了传统开发模式的简单实用性. 为快速开发减 ...