sqlsql必知必会_01

Posted 9513-

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sqlsql必知必会_01相关的知识,希望对你有一定的参考价值。

数据:

  1 /*
  2  Navicat Premium Data Transfer
  3 
  4  Source Server         : localhost_3306
  5  Source Server Type    : mysql
  6  Source Server Version : 80013
  7  Source Host           : localhost:3306
  8  Source Schema         : wucai
  9 
 10  Target Server Type    : MySQL
 11  Target Server Version : 80013
 12  File Encoding         : 65001
 13 
 14  Date: 03/07/2019 12:09:58
 15 */
 16 
 17 SET NAMES utf8mb4;
 18 SET FOREIGN_KEY_CHECKS = 0;
 19 
 20 -- ----------------------------
 21 -- Table structure for heros
 22 -- ----------------------------
 23 DROP TABLE IF EXISTS `heros`;
 24 CREATE TABLE `heros`  (
 25   `id` int(11) NOT NULL AUTO_INCREMENT,
 26   `name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
 27   `hp_max` float NULL DEFAULT NULL,
 28   `hp_growth` float NULL DEFAULT NULL,
 29   `hp_start` float NULL DEFAULT NULL,
 30   `mp_max` float NULL DEFAULT NULL,
 31   `mp_growth` float NULL DEFAULT NULL,
 32   `mp_start` float NULL DEFAULT NULL,
 33   `attack_max` float NULL DEFAULT NULL,
 34   `attack_growth` float NULL DEFAULT NULL,
 35   `attack_start` float NULL DEFAULT NULL,
 36   `defense_max` float NULL DEFAULT NULL,
 37   `defense_growth` float NULL DEFAULT NULL,
 38   `defense_start` float NULL DEFAULT NULL,
 39   `hp_5s_max` float NULL DEFAULT NULL,
 40   `hp_5s_growth` float NULL DEFAULT NULL,
 41   `hp_5s_start` float NULL DEFAULT NULL,
 42   `mp_5s_max` float NULL DEFAULT NULL,
 43   `mp_5s_growth` float NULL DEFAULT NULL,
 44   `mp_5s_start` float NULL DEFAULT NULL,
 45   `attack_speed_max` float NULL DEFAULT NULL,
 46   `attack_range` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
 47   `role_main` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
 48   `role_assist` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
 49   `birthdate` date NULL DEFAULT NULL,
 50   PRIMARY KEY (`id`) USING BTREE
 51 ) ENGINE = InnoDB AUTO_INCREMENT = 10069 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
 52 
 53 -- ----------------------------
 54 -- Records of heros
 55 -- ----------------------------
 56 INSERT INTO `heros` VALUES (10000, 夏侯惇, 7350, 288.8, 3307, 1746, 94, 430, 321, 11.57, 159, 397, 21.14, 101, 98, 3.357, 51, 37, 1.571, 15, 0, 近战, 坦克, 战士, 2016-07-19);
 57 INSERT INTO `heros` VALUES (10001, 钟无艳, 7000, 275, 3150, 1760, 95, 430, 318, 11, 164, 409, 22.07, 100, 92, 3.143, 48, 37, 1.571, 15, 0, 近战, 战士, 坦克, NULL);
 58 INSERT INTO `heros` VALUES (10002, 张飞, 8341, 329.4, 3450, 100, 0, 100, 301, 10.57, 153, 504, 27.07, 125, 115, 4.143, 57, 5, 0, 5, 0, 近战, 坦克, 辅助, NULL);
 59 INSERT INTO `heros` VALUES (10003, 牛魔, 8476, 352.8, 3537, 1926, 104, 470, 273, 8.357, 156, 394, 20.36, 109, 117, 4.214, 58, 42, 1.786, 17, 0, 近战, 坦克, 辅助, 2015-11-24);
 60 INSERT INTO `heros` VALUES (10004, 吕布, 7344, 270, 3564, 0, 0, 0, 343, 12.36, 170, 390, 20.79, 99, 97, 3.071, 54, 0, 0, 0, 0, 近战, 战士, 坦克, 2015-12-22);
 61 INSERT INTO `heros` VALUES (10005, 亚瑟, 8050, 316.3, 3622, 0, 0, 0, 346, 13, 164, 400, 21.57, 98, 106, 3.643, 55, 0, 0, 0, 0, 近战, 战士, 坦克, NULL);
 62 INSERT INTO `heros` VALUES (10006, 芈月, 6164, 281.5, 3105, 100, 0, 100, 289, 9.786, 152, 361, 19.5, 88, 77, 2.357, 44, 0, 0, 0, 0, 远程, 法师, 坦克, 2015-12-08);
 63 INSERT INTO `heros` VALUES (10007, 程咬金, 8611, 369.6, 3437, 0, 0, 0, 316, 11.07, 161, 504, 27.07, 125, 119, 4.429, 57, 0, 0, 0, 0, 近战, 坦克, 战士, NULL);
 64 INSERT INTO `heros` VALUES (10008, 廉颇, 9328, 412.1, 3558, 1708, 92, 420, 286, 8.786, 163, 514, 27.29, 132, 128, 4.929, 59, 36, 1.5, 15, 0, 近战, 坦克, NULL, NULL);
 65 INSERT INTO `heros` VALUES (10009, 东皇太一, 7669, 319.1, 3201, 1926, 104, 470, 286, 8.786, 163, 360, 18.64, 99, 106, 3.786, 53, 42, 1.786, 17, 0, 近战, 坦克, NULL, 2017-03-30);
 66 INSERT INTO `heros` VALUES (10010, 庄周, 8149, 345.6, 3311, 1694, 91, 420, 297, 9.071, 170, 497, 24.79, 150, 113, 4.143, 55, 36, 1.5, 15, 0, 近战, 辅助, 坦克, NULL);
 67 INSERT INTO `heros` VALUES (10011, 太乙真人, 6835, 242.3, 3443, 1680, 90, 420, 284, 9.286, 154, 396, 21.57, 94, 86, 2.643, 49, 35, 1.429, 15, 0, 近战, 辅助, 坦克, 2016-11-24);
 68 INSERT INTO `heros` VALUES (10012, 白起, 8638, 366.3, 3510, 1666, 89, 420, 288, 9.286, 158, 430, 22.14, 120, 119, 4.357, 58, 34, 1.429, 14, 0, 近战, 坦克, NULL, NULL);
 69 INSERT INTO `heros` VALUES (10013, 雅典娜, 6264, 243, 2862, 1732, 93, 430, 327, 11.79, 162, 418, 22.29, 106, 83, 2.786, 44, 36, 1.5, 15, 0, 近战, 战士, 坦克, NULL);
 70 INSERT INTO `heros` VALUES (10014, 刘邦, 8073, 336, 3369, 1940, 105, 470, 302, 10.29, 158, 504, 27.07, 125, 117, 4.214, 58, 42, 1.786, 17, 0, 近战, 坦克, 辅助, 2016-04-26);
 71 INSERT INTO `heros` VALUES (10015, 刘禅, 8581, 372.6, 3364, 1694, 91, 420, 295, 8.357, 178, 459, 22.86, 139, 118, 4.429, 56, 36, 1.5, 15, 0, 近战, 坦克, NULL, NULL);
 72 INSERT INTO `heros` VALUES (10016, 墨子, 7176, 292.4, 3083, 1722, 93, 420, 328, 10.5, 181, 475, 26.64, 102, 100, 3.5, 51, 37, 1.571, 15, 0, 近战, 法师, 坦克, NULL);
 73 INSERT INTO `heros` VALUES (10017, 项羽, 8057, 380.1, 3535, 1694, 91, 420, 306, 10.64, 157, 494, 26.5, 123, 121, 4.5, 58, 36, 1.5, 15, 0, 近战, 坦克, NULL, NULL);
 74 INSERT INTO `heros` VALUES (10018, 关羽, 7107, 270.4, 3322, 10, 0, 10, 343, 12.36, 170, 386, 20.36, 101, 94, 3.071, 51, 0, 0, 0, 0, 近战, 战士, 坦克, 2016-06-28);
 75 INSERT INTO `heros` VALUES (10019, 后羿, 5986, 200.3, 3182, 1784, 96, 440, 396, 16.79, 161, 336, 17.86, 86, 71, 2.143, 41, 38, 1.571, 16, 0, 远程, 射手, NULL, NULL);
 76 INSERT INTO `heros` VALUES (10020, 马可波罗, 5584, 181.6, 3041, 200, 0, 200, 362, 13.36, 175, 344, 18.07, 91, 75, 2.071, 46, 50, 0, 50, 0, 远程, 射手, NULL, 2016-08-23);
 77 INSERT INTO `heros` VALUES (10021, 鲁班七号, 5989, 184.9, 3401, 1756, 94, 440, 400, 16.14, 174, 323, 16.79, 88, 69, 1.929, 42, 36, 1.5, 15, 0, 远程, 射手, NULL, NULL);
 78 INSERT INTO `heros` VALUES (10022, 李元芳, 5725, 194.1, 3007, 1770, 95, 440, 396, 16.79, 161, 340, 18.07, 87, 66, 2.071, 37, 37, 1.571, 15, 0, 远程, 射手, NULL, 2016-04-12);
 79 INSERT INTO `heros` VALUES (10023, 孙尚香, 6014, 198.5, 3235, 1756, 94, 440, 411, 17.07, 172, 346, 18.36, 89, 69, 2.071, 40, 36, 1.5, 15, 0, 远程, 射手, NULL, NULL);
 80 INSERT INTO `heros` VALUES (10024, 黄忠, 5898, 194.6, 3173, 1784, 96, 440, 403, 16.5, 172, 319, 16.29, 91, 68, 2.071, 39, 38, 1.571, 16, 0, 远程, 射手, NULL, NULL);
 81 INSERT INTO `heros` VALUES (10025, 狄仁杰, 5710, 176.3, 3242, 1770, 95, 440, 376, 14.79, 169, 338, 17.36, 95, 66, 1.857, 40, 37, 1.571, 15, 0, 远程, 射手, NULL, NULL);
 82 INSERT INTO `heros` VALUES (10026, 虞姬, 5669, 192.3, 2977, 1770, 95, 440, 407, 17.29, 165, 329, 17.5, 84, 63, 1.929, 36, 38, 1.571, 16, 0, 远程, 射手, NULL, 2016-05-24);
 83 INSERT INTO `heros` VALUES (10027, 成吉思汗, 5799, 198, 3027, 1742, 93, 440, 394, 15, 184, 329, 16.79, 94, 66, 2.071, 37, 36, 1.5, 15, 0, 远程, 射手, NULL, 2016-09-27);
 84 INSERT INTO `heros` VALUES (10028, 嬴政, 5471, 167.6, 3125, 1946, 104, 490, 309, 10.86, 157, 295, 14.57, 91, 70, 1.857, 44, 41, 1.714, 17, 0, 远程, 法师, NULL, NULL);
 85 INSERT INTO `heros` VALUES (10029, 武则天, 5037, 155.5, 2860, 1988, 107, 490, 297, 8.857, 173, 348, 18.07, 95, 64, 1.714, 40, 43, 1.786, 18, 0, 远程, 法师, NULL, NULL);
 86 INSERT INTO `heros` VALUES (10030, 露娜, 6612, 256.5, 3021, 1836, 99, 450, 335, 12.29, 163, 375, 19.5, 102, 99, 3.357, 52, 39, 1.643, 16, 0, 近战, 战士, 法师, NULL);
 87 INSERT INTO `heros` VALUES (10031, 甄姬, 5584, 181.6, 3041, 2002, 108, 490, 296, 9.357, 165, 330, 17.36, 87, 71, 2, 43, 44, 1.857, 18, 0, 远程, 法师, NULL, NULL);
 88 INSERT INTO `heros` VALUES (10032, 妲己, 5824, 185.4, 3229, 2016, 109, 490, 293, 8.786, 170, 326, 17.14, 86, 74, 2, 46, 44, 1.857, 18, 0, 远程, 法师, NULL, NULL);
 89 INSERT INTO `heros` VALUES (10033, 干将莫邪, 5583, 171, 3189, 1946, 104, 490, 292, 9.5, 159, 323, 16.5, 92, 71, 1.857, 45, 41, 1.714, 17, 0, 远程, 法师, NULL, 2017-05-22);
 90 INSERT INTO `heros` VALUES (10034, 姜子牙, 5399, 174.4, 2958, 2002, 108, 490, 317, 10.64, 168, 342, 16.86, 106, 69, 1.929, 42, 44, 1.857, 18, 0, 远程, 法师, 辅助, NULL);
 91 INSERT INTO `heros` VALUES (10035, 王昭君, 5429, 167.6, 3083, 1960, 105, 490, 296, 9.357, 165, 305, 15.29, 91, 70, 1.857, 44, 41, 1.714, 17, 0, 远程, 法师, NULL, NULL);
 92 INSERT INTO `heros` VALUES (10036, 诸葛亮, 5655, 180, 3135, 1988, 107, 490, 287, 9.357, 156, 330, 17.36, 87, 72, 2, 44, 43, 1.786, 18, 0, 远程, 法师, NULL, NULL);
 93 INSERT INTO `heros` VALUES (10037, 不知火舞, 6014, 198.5, 3235, 200, 0, 200, 293, 8.786, 170, 336, 17.64, 89, 76, 2.143, 46, 50, 0, 50, 0, 近战, 法师, 刺客, 2016-05-12);
 94 INSERT INTO `heros` VALUES (10038, 貂蝉, 5611, 185.1, 3019, 1960, 105, 490, 287, 8.571, 167, 330, 17.36, 87, 71, 2, 43, 41, 1.714, 17, 0, 近战, 法师, 刺客, 2015-12-15);
 95 INSERT INTO `heros` VALUES (10039, 孙膑, 6811, 257.4, 3208, 1926, 104, 470, 328, 10.86, 176, 413, 22.5, 98, 85, 2.857, 45, 42, 1.786, 17, 0, 远程, 辅助, 法师, NULL);
 96 INSERT INTO `heros` VALUES (10040, 安琪拉, 5994, 190.8, 3323, 1960, 105, 490, 293, 8.786, 170, 315, 16.57, 83, 76, 2.071, 47, 41, 1.714, 17, 0, 远程, 法师, NULL, NULL);
 97 INSERT INTO `heros` VALUES (10041, 小乔, 5916, 202, 3088, 1988, 107, 490, 263, 7.857, 153, 309, 15.29, 95, 75, 2.214, 44, 43, 1.786, 18, 0, 远程, 法师, NULL, NULL);
 98 INSERT INTO `heros` VALUES (10042, 周瑜, 5513, 172.9, 3093, 1974, 106, 490, 298, 9.857, 160, 320, 16.64, 87, 70, 1.857, 44, 42, 1.786, 17, 0, 远程, 法师, NULL, 2015-11-10);
 99 INSERT INTO `heros` VALUES (10043, 张良, 5799, 198, 3027, 1988, 107, 490, 293, 8.786, 170, 320, 16.64, 87, 73, 2.143, 43, 43, 1.786, 18, 0, 远程, 法师, NULL, 2015-10-26);
100 INSERT INTO `heros` VALUES (10044, 高渐离, 6165, 217.4, 3122, 1988, 107, 490, 290, 9.071, 163, 343, 17.5, 98, 77, 2.357, 44, 42, 1.786, 17, 0, 远程, 法师, NULL, NULL);
101 INSERT INTO `heros` VALUES (10045, 扁鹊, 6703, 249.9, 3205, 2016, 109, 490, 309, 10.07, 168, 374, 20.5, 87, 83, 2.714, 45, 44, 1.857, 18, 0, 远程, 法师, 辅助, NULL);
102 INSERT INTO `heros` VALUES (10046, 钟馗, 6280, 204.3, 3420, 1988, 107, 490, 278, 8.286, 162, 390, 20.79, 99, 91, 2.429, 57, 42, 1.786, 17, 0, 近战, 法师, 战士, 2016-03-24);
103 INSERT INTO `heros` VALUES (10047, 大乔, 5399, 174.4, 2958, 1926, 104, 470, 305, 9.786, 168, 340, 17.64, 93, 69, 1.929, 42, 42, 1.786, 17, 0, 近战, 辅助, NULL, 2017-02-28);
104 INSERT INTO `heros` VALUES (10048, 鬼谷子, 7107, 270.4, 3322, 1808, 97, 450, 297, 9.643, 162, 394, 21.57, 92, 89, 3, 47, 38, 1.571, 16, 0, 近战, 辅助, NULL, 2017-06-29);
105 INSERT INTO `heros` VALUES (10049, 蔡文姬, 5910, 190.9, 3238, 1898, 102, 470, 292, 9.5, 159, 350, 18.14, 96, 66, 2, 38, 41, 1.714, 17, 0, 远程, 辅助, NULL, 2016-07-08);
106 INSERT INTO `heros` VALUES (10050, 花木兰, 5397, 179.4, 2886, 100, 0, 100, 362, 14, 166, 349, 18.79, 86, 72, 2, 44, 0, 0, 0, 0, 近战, 战士, 刺客, 2016-01-01);
107 INSERT INTO `heros` VALUES (10051, 赵云, 6732, 247.5, 3267, 1760, 95, 430, 380, 14.79, 173, 394, 22.14, 84, 89, 2.786, 50, 37, 1.571, 15, 0, 近战, 战士, 刺客, NULL);
108 INSERT INTO `heros` VALUES (10052, 橘石京, 7000, 275, 3150, 0, 0, 0, 347, 13, 165, 392, 21.14, 96, 92, 3.143, 48, 0, 0, 0, 0, 近战, 刺客, 战士, NULL);
109 INSERT INTO `heros` VALUES (10053, 李白, 5483, 179.6, 2968, 1808, 97, 450, 330, 11.5, 169, 358, 18.57, 98, 80, 2.214, 49, 38, 1.571, 16, 0, 近战, 刺客, 战士, 2016-03-01);
110 INSERT INTO `heros` VALUES (10054, 韩信, 5655, 190.5, 2988, 1704, 91, 430, 386, 15.29, 172, 323, 16.5, 92, 75, 2.143, 45, 36, 1.5, 15, 0, 近战, 刺客, 战士, NULL);
111 INSERT INTO `heros` VALUES (10055, 杨戬, 7420, 291.5, 3339, 1694, 91, 420, 325, 11.36, 166, 428, 23.57, 98, 98, 3.357, 51, 36, 1.5, 15, 0, 近战, 战士, NULL, 2016-10-11);
112 INSERT INTO `heros` VALUES (10056, 达摩, 7140, 280.5, 3213, 1694, 91, 420, 355, 13.14, 171, 415, 22.86, 95, 98, 3.357, 51, 36, 1.5, 15, 0, 近战, 战士, NULL, NULL);
113 INSERT INTO `heros` VALUES (10057, 孙悟空, 6585, 235.1, 3293, 1760, 95, 430, 349, 13, 167, 385, 20.79, 94, 87, 2.643, 50, 37, 1.571, 15, 0, 近战, 战士, 刺客, NULL);
114 INSERT INTO `heros` VALUES (10058, 刘备, 6900, 262.5, 3225, 1742, 93, 440, 363, 14.29, 163, 381, 19.14, 113, 79, 2.786, 40, 36, 1.5, 15, 0, 远程, 战士, NULL, 2016-02-02);
115 INSERT INTO `heros` VALUES (10059, 曹操, 7473, 286.1, 3467, 0, 0, 0, 361, 13.36, 174, 371, 19.07, 104, 101, 3.357, 54, 0, 0, 0, 0, 近战, 战士, NULL, NULL);
116 INSERT INTO `heros` VALUES (10060, 典韦, 7516, 291.6, 3434, 1774, 96, 430, 345, 12.64, 168, 402, 22.36, 89, 99, 3.357, 52, 39, 1.643, 16, 0, 近战, 战士, NULL, NULL);
117 INSERT INTO `heros` VALUES (10061, 宫本武藏, 6210, 236.3, 2902, 0, 0, 0, 330, 12.36, 157, 391, 20.36, 106, 85, 2.714, 47, 0, 0, 0, 0, 近战, 战士, NULL, 2015-10-30);
118 INSERT INTO `heros` VALUES (10062, 老夫子, 7155, 270.4, 3370, 5, 0, 5, 329, 11.5, 168, 409, 22.07, 100, 94, 3.071, 51, 0, 0, 0, 1, 近战, 战士, NULL, NULL);
119 INSERT INTO `heros` VALUES (10063, 哪吒, 7268, 270.4, 3483, 1808, 97, 450, 320, 11.5, 159, 408, 22.07, 99, 98, 3.214, 53, 38, 1.571, 16, 0, 近战, 战士, NULL, 2017-01-12);
120 INSERT INTO `heros` VALUES (10064, 阿轲, 5968, 192.8, 3269, 0, 0, 0, 427, 17.86, 177, 349, 18.57, 89, 81, 2.214, 50, 0, 0, 0, 0, 近战, 刺客, NULL, NULL);
121 INSERT INTO `heros` VALUES (10065, 娜可露露, 6205, 211.9, 3239, 1808, 97, 450, 385, 15.14, 173, 359, 19.5, 86, 79, 2.286, 47, 38, 1.571, 16, 0, 近战, 刺客, NULL, 2016-02-22);
122 INSERT INTO `heros` VALUES (10066, 兰陵王, 6232, 210, 3292, 1822, 98, 450, 388, 15.5, 171, 342, 18.36, 85, 99, 3.357, 52, 46, 1.929, 19, 0, 近战, 刺客, NULL, NULL);
123 INSERT INTO `heros` VALUES (10067, , 6700, 237.5, 3375, 1784, 96, 440, 328, 10.86, 176, 388, 20.07, 107, 81, 2.643, 44, 38, 1.571, 16, 0, 近战, 战士, 坦克, NULL);
124 INSERT INTO `heros` VALUES (10068, 百里守约, 5611, 185.1, 3019, 1784, 96, 440, 410, 15.86, 188, 329, 16.79, 94, 68, 2.071, 39, 38, 1.571, 16, 0, 远程, 射手, 刺客, 2017-08-08);
125 
126 SET FOREIGN_KEY_CHECKS = 1;
 1 /*
 2  Navicat Premium Data Transfer
 3 
 4  Source Server         : localhost_3306
 5  Source Server Type    : MySQL
 6  Source Server Version : 80013
 7  Source Host           : localhost:3306
 8  Source Schema         : wucai
 9 
10  Target Server Type    : MySQL
11  Target Server Version : 80013
12  File Encoding         : 65001
13 
14  Date: 18/04/2019 14:14:42
15 */
16 
17 SET NAMES utf8mb4;
18 SET FOREIGN_KEY_CHECKS = 0;
19 
20 -- ----------------------------
21 -- Table structure for height_grades
22 -- ----------------------------
23 DROP TABLE IF EXISTS `height_grades`;
24 CREATE TABLE `height_grades`  (
25   `height_level` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
26   `height_lowest` float(3, 2) NOT NULL,
27   `height_highest` float(3, 2) NOT NULL
28 ) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
29 
30 -- ----------------------------
31 -- Records of height_grades
32 -- ----------------------------
33 INSERT INTO `height_grades` VALUES (A, 2.00, 2.50);
34 INSERT INTO `height_grades` VALUES (B, 1.90, 1.99);
35 INSERT INTO `height_grades` VALUES (C, 1.80, 1.89);
36 INSERT INTO `height_grades` VALUES (D, 1.60, 1.79);
37 
38 SET FOREIGN_KEY_CHECKS = 1;
 1 /*
 2  Navicat Premium Data Transfer
 3 
 4  Source Server         : localhost_3306
 5  Source Server Type    : MySQL
 6  Source Server Version : 80013
 7  Source Host           : localhost:3306
 8  Source Schema         : wucai
 9 
10  Target Server Type    : MySQL
11  Target Server Version : 80013
12  File Encoding         : 65001
13 
14  Date: 25/06/2019 23:46:41
15 */
16 
17 SET NAMES utf8mb4;
18 SET FOREIGN_KEY_CHECKS = 0;
19 
20 -- ----------------------------
21 -- Table structure for player_score
22 -- ----------------------------
23 DROP TABLE IF EXISTS `player_score`;
24 CREATE TABLE `player_score`  (
25   `game_id` int(11) NOT NULL,
26   `player_id` int(11) NOT NULL,
27   `is_first` tinyint(1) NOT NULL,
28   `playing_time` int(11) NOT NULL,
29   `rebound` int(11) NOT NULL,
30   `rebound_o` int(11) NOT NULL,
31   `rebound_d` int(11) NOT NULL,
32   `assist` int(11) NOT NULL,
33   `score` int(11) NOT NULL,
34   `steal` int(11) NOT NULL,
35   `blockshot` int(11) NOT NULL,
36   `fault` int(11) NOT NULL,
37   `foul` int(11) NOT NULL,
38   `shoot_attempts` int(11) NOT NULL,
39   `shoot_hits` int(11) NOT NULL,
40   `shoot_3_attempts` int(11) NOT NULL,
41   `shoot_3_hits` int(11) NOT NULL,
42   `shoot_p_attempts` int(11) NOT NULL,
43   `shoot_p_hits` int(11) NOT NULL
44 ) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
45 
46 -- ----------------------------
47 -- Records of player_score
48 -- ----------------------------
49 INSERT INTO `player_score` VALUES (10001, 10001, 1, 38, 4, 1, 3, 2, 26, 0, 1, 0, 3, 19, 10, 13, 4, 4, 2);
50 INSERT INTO `player_score` VALUES (10001, 10002, 1, 30, 6, 4, 2, 4, 22, 0, 0, 6, 3, 19, 8, 5, 1, 5, 5);
51 INSERT INTO `player_score` VALUES (10001, 10003, 1, 37, 17, 7, 10, 5, 18, 4, 0, 3, 4, 18, 8, 1, 0, 5, 2);
52 INSERT INTO `player_score` VALUES (10001, 10004, 1, 42, 6, 1, 5, 2, 14, 0, 4, 1, 2, 10, 4, 7, 4, 2, 2);
53 INSERT INTO `player_score` VALUES (10001, 10005, 1, 19, 2, 0, 2, 2, 0, 2, 0, 1, 1, 1, 0, 1, 0, 0, 0);
54 INSERT INTO `player_score` VALUES (10001, 10006, 0, 23, 2, 2, 0, 1, 9, 1, 0, 0, 2, 10, 3, 3, 2, 1, 1);
55 INSERT INTO `player_score` VALUES (10001, 10007, 0, 13, 1, 1, 0, 1, 7, 0, 0, 0, 2, 4, 2, 2, 1, 2, 2);
56 INSERT INTO `player_score` VALUES (10001, 10008, 0, 20, 2, 0, 2, 3, 6, 0, 0, 3, 3, 5, 3, 0, 0, 0, 0);
57 INSERT INTO `player_score` VALUES (10001, 10009, 0, 11, 1, 0, 1, 1, 0, 0, 0, 1, 4, 0, 0, 0, 0, 0, 0);
58 INSERT INTO `player_score` VALUES (10001, 10010, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 1, 0, 0, 0);
59 INSERT INTO `player_score` VALUES (10002, 10022, 1, 37, 7, 1, 6, 6, 19, 3, 0, 1, 3, 16, 7, 3, 1, 4, 4);
60 INSERT INTO `player_score` VALUES (10002, 10025, 1, 34, 9, 1, 8, 5, 19, 0, 0, 5, 1, 12, 8, 0, 0, 4, 3);
61 INSERT INTO `player_score` VALUES (10002, 10024, 1, 34, 6, 0, 6, 0, 17, 3, 5, 0, 2, 7, 5, 3, 2, 6, 5);
62 INSERT INTO `player_score` VALUES (10002, 10028, 1, 27, 3, 0, 3, 3, 13, 1, 1, 3, 1, 10, 4, 6, 4, 2, 1);
63 INSERT INTO `player_score` VALUES (10002, 10030, 1, 31, 1, 0, 1, 3, 4, 2, 0, 1, 2, 9, 2, 3, 0, 0, 0);
64 INSERT INTO `player_score` VALUES (10002, 10023, 0, 23, 12, 4, 8, 3, 18, 0, 0, 3, 6, 10, 8, 0, 0, 2, 2);
65 INSERT INTO `player_score` VALUES (10002, 10029, 0, 24, 2, 1, 1, 2, 11, 0, 0, 1, 2, 8, 5, 3, 1, 0, 0);
66 INSERT INTO `player_score` VALUES (10002, 10031, 0, 25, 1, 0, 1, 5, 10, 0, 1, 2, 3, 4, 3, 3, 2, 4, 2);
67 INSERT INTO `player_score` VALUES (10002, 10032, 0, 4, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0);
68 
69 SET FOREIGN_KEY_CHECKS = 1;
 1 /*
 2  Navicat Premium Data Transfer
 3 
 4  Source Server         : localhost_3306
 5  Source Server Type    : MySQL
 6  Source Server Version : 80013
 7  Source Host           : localhost:3306
 8  Source Schema         : wucai
 9 
10  Target Server Type    : MySQL
11  Target Server Version : 80013
12  File Encoding         : 65001
13 
14  Date: 18/04/2019 14:14:56
15 */
16 
17 SET NAMES utf8mb4;
18 SET FOREIGN_KEY_CHECKS = 0;
19 
20 -- ----------------------------
21 -- Table structure for player
22 -- ----------------------------
23 DROP TABLE IF EXISTS `player`;
24 CREATE TABLE `player`  (
25   `player_id` int(11) NOT NULL AUTO_INCREMENT,
26   `team_id` int(11) NOT NULL,
27   `player_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
28   `height` float(3, 2) NULL DEFAULT NULL,
29   PRIMARY KEY (`player_id`) USING BTREE,
30   UNIQUE INDEX `player_name`(`player_name`) USING BTREE
31 ) ENGINE = InnoDB AUTO_INCREMENT = 10038 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
32 
33 -- ----------------------------
34 -- Records of player
35 -- ----------------------------
36 INSERT INTO `player` VALUES (10001, 1001, 韦恩-艾灵顿, 1.93);
37 INSERT INTO `player` VALUES (10002, 1001, 雷吉-杰克逊, 1.91);
38 INSERT INTO `player` VALUES (10003, 1001, 安德烈-德拉蒙德, 2.11);
39 INSERT INTO `player` VALUES (10004, 1001, 索恩-马克, 2.16);
40 INSERT INTO `player` VALUES (10005, 1001, 布鲁斯-布朗, 1.96);
41 INSERT INTO `player` VALUES (10006, 1001, 兰斯顿-加洛韦, 1.88);
42 INSERT INTO `player` VALUES (10007, 1001, 格伦-罗宾逊三世, 1.98);
43 INSERT INTO `player` VALUES (10008, 1001, 伊斯梅尔-史密斯, 1.83);
44 INSERT INTO `player` VALUES (10009, 1001, 扎扎-帕楚里亚, 2.11);
45 INSERT INTO `player` VALUES (10010, 1001, 乔恩-洛伊尔, 2.08);
46 INSERT INTO `player` VALUES (10011, 1001, 布雷克-格里芬, 2.08);
47 INSERT INTO `player` VALUES (10012, 1001, 雷吉-巴洛克, 2.01);
48 INSERT INTO `player` VALUES (10013, 1001, 卢克-肯纳德, 1.96);
49 INSERT INTO `player` VALUES (10014, 1001, 斯坦利-约翰逊, 2.01);
50 INSERT INTO `player` VALUES (10015, 1001, 亨利-埃伦森, 2.11);
51 INSERT INTO `player` VALUES (10016, 1001, 凯里-托马斯, 1.91);
52 INSERT INTO `player` VALUES (10017, 1001, 何塞-卡尔德隆, 1.91);
53 INSERT INTO `player` VALUES (10018, 1001, 斯维亚托斯拉夫-米凯卢克, 2.03);
54 INSERT INTO `player` VALUES (10019, 1001, 扎克-洛夫顿, 1.93);
55 INSERT INTO `player` VALUES (10020, 1001, 卡林-卢卡斯, 1.85);
56 INSERT INTO `player` VALUES (10021, 1002, 维克多-奥拉迪波, 1.93);
57 INSERT INTO `player` VALUES (10022, 1002, 博扬-博格达诺维奇, 2.03);
58 INSERT INTO `player` VALUES (10023, 1002, 多曼塔斯-萨博尼斯, 2.11);
59 INSERT INTO `player` VALUES (10024, 1002, 迈尔斯-特纳, 2.11);
60 INSERT INTO `player` VALUES (10025, 1002, 赛迪斯-杨, 2.03);
61 INSERT INTO `player` VALUES (10026, 1002, 达伦-科里森, 1.83);
62 INSERT INTO `player` VALUES (10027, 1002, 韦斯利-马修斯, 1.96);
63 INSERT INTO `player` VALUES (10028, 1002, 泰瑞克-埃文斯, 1.98);
64 INSERT INTO `player` VALUES (10029, 1002, 道格-迈克德莫特, 2.03);
65 INSERT INTO `player` VALUES (10030, 1002, 科里-约瑟夫, 1.91);
66 INSERT INTO `player` VALUES (10031, 1002, 阿龙-霍勒迪, 1.85);
67 INSERT INTO `player` VALUES (10032, 1002, TJ-利夫, 2.08);
68 INSERT INTO `player` VALUES (10033, 1002, 凯尔-奥奎因, 2.08);
69 INSERT INTO `player` VALUES (10034, 1002, 埃德蒙-萨姆纳, 1.96);
70 INSERT INTO `player` VALUES (10035, 1002, 达文-里德, 1.98);
71 INSERT INTO `player` VALUES (10036, 1002, 阿利兹-约翰逊, 2.06);
72 INSERT INTO `player` VALUES (10037, 1002, Ike Anigbogu, 2.08);
73 
74 SET FOREIGN_KEY_CHECKS = 1;
 1 /*
 2  Navicat Premium Data Transfer
 3 
 4  Source Server         : localhost_3306
 5  Source Server Type    : MySQL
 6  Source Server Version : 80013
 7  Source Host           : localhost:3306
 8  Source Schema         : wucai
 9 
10  Target Server Type    : MySQL
11  Target Server Version : 80013
12  File Encoding         : 65001
13 
14  Date: 25/06/2019 23:46:15
15 */
16 
17 SET NAMES utf8mb4;
18 SET FOREIGN_KEY_CHECKS = 0;
19 
20 -- ----------------------------
21 -- Table structure for team_score
22 -- ----------------------------
23 DROP TABLE IF EXISTS `team_score`;
24 CREATE TABLE `team_score`  (
25   `game_id` int(11) NOT NULL,
26   `h_team_id` int(11) NOT NULL,
27   `v_team_id` int(11) NOT NULL,
28   `h_team_score` int(11) NOT NULL,
29   `v_team_score` int(11) NOT NULL,
30   `game_date` date NULL DEFAULT NULL,
31   PRIMARY KEY (`game_id`) USING BTREE
32 ) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
33 
34 -- ----------------------------
35 -- Records of team_score
36 -- ----------------------------
37 INSERT INTO `team_score` VALUES (10001, 1001, 1002, 102, 111, 2019-04-01);
38 INSERT INTO `team_score` VALUES (10002, 1002, 1003, 135, 134, 2019-04-10);
39 
40 SET FOREIGN_KEY_CHECKS = 1;
 1 /*
 2  Navicat Premium Data Transfer
 3 
 4  Source Server         : localhost_3306
 5  Source Server Type    : MySQL
 6  Source Server Version : 80013
 7  Source Host           : localhost:3306
 8  Source Schema         : wucai
 9 
10  Target Server Type    : MySQL
11  Target Server Version : 80013
12  File Encoding         : 65001
13 
14  Date: 18/04/2019 14:15:06
15 */
16 
17 SET NAMES utf8mb4;
18 SET FOREIGN_KEY_CHECKS = 0;
19 
20 -- ----------------------------
21 -- Table structure for team
22 -- ----------------------------
23 DROP TABLE IF EXISTS `team`;
24 CREATE TABLE `team`  (
25   `team_id` int(11) NOT NULL,
26   `team_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
27   PRIMARY KEY (`team_id`) USING BTREE
28 ) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
29 
30 -- ----------------------------
31 -- Records of team
32 -- ----------------------------
33 INSERT INTO `team` VALUES (1001, 底特律活塞);
34 INSERT INTO `team` VALUES (1002, 印第安纳步行者);
35 INSERT INTO `team` VALUES (1003, 亚特兰大老鹰);
36 
37 SET FOREIGN_KEY_CHECKS = 1;

 

 

chapter1 - chapter8 ...

chapter9 子查询
 
关键字in和exists如何选择?
e.g.
SELECT * FROM A WHERE cc IN (SELECT cc FROM B)
SELECT * FROM A WHERE EXIST (SELECT cc FROM B WHERE B.cc=A.cc)
 
实际上在查询过程中,在我们对 cc 列建立索引的情况下,还需要比较A表和B表的大小。
在这个例子中,表 A 指的是 player 表,表 B 指的是 player_socre表。如果表A比表B大,那么IN比EXISTS的查询效率高,因为B表对cc列创建了索引,那么IN子查询的效率高。
 
如果A表比B表小,那么使用EXISTS效率高,因为可以使用到A表中对cc列的索引,而不用从B表中进行cc列的查询。
 
IN表是外边和内表进行hash连接,是先执行子查询。
EXISTS是对外表进行循环,然后在内表进行查询。
因此如果外表数据量大,则用IN,如果外表数据量小,也用EXISTS。
IN有一个缺陷是不能判断NULL,因此如果字段存在NULL值,则会出现返回,因为最好使用NOT EXISTS。
 
 1 #9-1 筛选最大生命值大于 6000 的英雄,按照主要定位进行分组,按照分组英雄数从高到低进行排序,并显示每个分组的英雄数量、主要定位和平均最大生命值。
 2 SELECT
 3     COUNT( * ) AS num,
 4     role_main,
 5     AVG(hp_max) 
 6 FROM
 7     heros 
 8 WHERE
 9     hp_max > 6000 
10 GROUP BY
11     role_main 
12 HAVING
13     num > 5 
14 ORDER BY
15     num DESC;
 1 #9-2 筛选最大生命值与最大法力值之和大于 7000 的英雄,按照攻击范围来进行分组,显示分组的英雄数量,以及分组英雄的最大生命值与法力值之和的平均值、最大值和最小值,并按照分组英雄数从高到低进行排序,其中聚集函数的结果包括小数点后两位。
 2 SELECT
 3     COUNT( * ) AS num,
 4     ROUND( AVG( hp_max + mp_max ), 2 ),
 5     ROUND( MAX( hp_max + mp_max ), 2 ),
 6     ROUND( MIN( hp_max + mp_max ), 2 ) 
 7 FROM
 8     heros 
 9 WHERE
10     hp_max + mp_max > 7000 
11 GROUP BY
12     attack_range 
13 ORDER BY
14     num DESC;
 1 #9-3 得到场均得分大于 20 的球员。场均得分从 player_score 表中获取,同时你需要输出球员的 ID、球员姓名以及所在球队的 ID 信息。
 2 SELECT
 3     player.player_id,
 4     player.player_name,
 5     player.team_id 
 6 FROM
 7     player 
 8 WHERE
 9     player.player_id IN (
10     SELECT
11         player_score.player_id 
12     FROM
13         player_score 
14     GROUP BY
15         player_score.player_id 
16     HAVING
17         AVG( player_score.score ) > 20 
18     );

 

 

 

 

 

 

以上是关于sqlsql必知必会_01的主要内容,如果未能解决你的问题,请参考以下文章

SQL必知必会

必知必会的设计原则——合成复用原则

《 MySQL必知必会》笔记_持续更新

深入理解Kafka必知必会

MySQL必知必会 第7-9章

01《正则表达式必知必会》(已看)(仅存放)