diff --git "a/05 \350\260\242\351\223\226\346\265\251/9.20.md" "b/05 \350\260\242\351\223\226\346\265\251/9.20.md" new file mode 100644 index 0000000000000000000000000000000000000000..a750feb85e8d51af308a79d4f45b9332e826f4ea --- /dev/null +++ "b/05 \350\260\242\351\223\226\346\265\251/9.20.md" @@ -0,0 +1,737 @@ +``` +create database text01 charset utf8; +use text01; +/* + Navicat Premium Data Transfer + + Source Server : local + Source Server Type : MySQL + Source Server Version : 80034 (8.0.34) + Source Host : localhost:3306 + Source Schema : mxdxdb + + Target Server Type : MySQL + Target Server Version : 80034 (8.0.34) + File Encoding : 65001 + + Date: 17/09/2023 22:21:02 +*/ + +SET NAMES utf8mb4; +SET FOREIGN_KEY_CHECKS = 0; + +-- ---------------------------- +-- Table structure for countries +-- ---------------------------- +DROP TABLE IF EXISTS `countries`; +CREATE TABLE `countries` ( + `country_id` char(2) NOT NULL, + `country_name` varchar(40) DEFAULT NULL, + `region_id` int DEFAULT NULL, + PRIMARY KEY (`country_id`), + KEY `countr_reg_fk` (`region_id`), + CONSTRAINT `countr_reg_fk` FOREIGN KEY (`region_id`) REFERENCES `regions` (`region_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; + +-- ---------------------------- +-- Records of countries +-- ---------------------------- +BEGIN; +INSERT INTO `countries` (`country_id`, `country_name`, `region_id`) VALUES ('AR', '阿根廷', 2); +INSERT INTO `countries` (`country_id`, `country_name`, `region_id`) VALUES ('AU', '澳大利亚', 3); +INSERT INTO `countries` (`country_id`, `country_name`, `region_id`) VALUES ('BE', '比利时', 1); +INSERT INTO `countries` (`country_id`, `country_name`, `region_id`) VALUES ('BR', '巴西', 2); +INSERT INTO `countries` (`country_id`, `country_name`, `region_id`) VALUES ('CA', '加拿大', 2); +INSERT INTO `countries` (`country_id`, `country_name`, `region_id`) VALUES ('CH', '瑞士', 1); +INSERT INTO `countries` (`country_id`, `country_name`, `region_id`) VALUES ('CN', '中国', 3); +INSERT INTO `countries` (`country_id`, `country_name`, `region_id`) VALUES ('DE', '德国', 1); +INSERT INTO `countries` (`country_id`, `country_name`, `region_id`) VALUES ('DK', '丹麦', 1); +INSERT INTO `countries` (`country_id`, `country_name`, `region_id`) VALUES ('EG', '埃及', 4); +INSERT INTO `countries` (`country_id`, `country_name`, `region_id`) VALUES ('FR', '法国', 1); +INSERT INTO `countries` (`country_id`, `country_name`, `region_id`) VALUES ('HK', '香港', 3); +INSERT INTO `countries` (`country_id`, `country_name`, `region_id`) VALUES ('IL', '以色列', 4); +INSERT INTO `countries` (`country_id`, `country_name`, `region_id`) VALUES ('IN', '印度', 3); +INSERT INTO `countries` (`country_id`, `country_name`, `region_id`) VALUES ('IT', '意大利', 1); +INSERT INTO `countries` (`country_id`, `country_name`, `region_id`) VALUES ('JP', '日本', 3); +INSERT INTO `countries` (`country_id`, `country_name`, `region_id`) VALUES ('KW', '科威特', 4); +INSERT INTO `countries` (`country_id`, `country_name`, `region_id`) VALUES ('MX', '墨西哥', 2); +INSERT INTO `countries` (`country_id`, `country_name`, `region_id`) VALUES ('NG', '尼日利亚', 4); +INSERT INTO `countries` (`country_id`, `country_name`, `region_id`) VALUES ('NL', '荷兰', 1); +INSERT INTO `countries` (`country_id`, `country_name`, `region_id`) VALUES ('SG', '新加坡', 3); +INSERT INTO `countries` (`country_id`, `country_name`, `region_id`) VALUES ('UK', '英国', 1); +INSERT INTO `countries` (`country_id`, `country_name`, `region_id`) VALUES ('US', '美国', 2); +INSERT INTO `countries` (`country_id`, `country_name`, `region_id`) VALUES ('ZM', '赞比亚', 4); +INSERT INTO `countries` (`country_id`, `country_name`, `region_id`) VALUES ('ZW', '津巴布韦', 4); +COMMIT; + +-- ---------------------------- +-- Table structure for departments +-- ---------------------------- +DROP TABLE IF EXISTS `departments`; +CREATE TABLE `departments` ( + `department_id` int NOT NULL DEFAULT '0', + `department_name` varchar(30) NOT NULL, + `manager_id` int DEFAULT NULL, + `location_id` int DEFAULT NULL, + PRIMARY KEY (`department_id`), + UNIQUE KEY `dept_id_pk` (`department_id`), + KEY `dept_loc_fk` (`location_id`), + KEY `dept_mgr_fk` (`manager_id`), + CONSTRAINT `dept_loc_fk` FOREIGN KEY (`location_id`) REFERENCES `locations` (`location_id`), + CONSTRAINT `dept_mgr_fk` FOREIGN KEY (`manager_id`) REFERENCES `employees` (`employee_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; + +-- ---------------------------- +-- Records of departments +-- ---------------------------- +BEGIN; +INSERT INTO `departments` (`department_id`, `department_name`, `manager_id`, `location_id`) VALUES (10, '行政部', 200, 1700); +INSERT INTO `departments` (`department_id`, `department_name`, `manager_id`, `location_id`) VALUES (20, '营销部', 201, 1800); +INSERT INTO `departments` (`department_id`, `department_name`, `manager_id`, `location_id`) VALUES (30, '采购部', 114, 1700); +INSERT INTO `departments` (`department_id`, `department_name`, `manager_id`, `location_id`) VALUES (40, '人力资源部', 203, 2400); +INSERT INTO `departments` (`department_id`, `department_name`, `manager_id`, `location_id`) VALUES (50, '物流部', 121, 1500); +INSERT INTO `departments` (`department_id`, `department_name`, `manager_id`, `location_id`) VALUES (60, '信息技术部', 103, 1400); +INSERT INTO `departments` (`department_id`, `department_name`, `manager_id`, `location_id`) VALUES (70, '公共关系部', 204, 2700); +INSERT INTO `departments` (`department_id`, `department_name`, `manager_id`, `location_id`) VALUES (80, '销售部', 145, 2500); +INSERT INTO `departments` (`department_id`, `department_name`, `manager_id`, `location_id`) VALUES (90, '执行部门', 100, 1700); +INSERT INTO `departments` (`department_id`, `department_name`, `manager_id`, `location_id`) VALUES (100, '财务部', 108, 1700); +INSERT INTO `departments` (`department_id`, `department_name`, `manager_id`, `location_id`) VALUES (110, '会计部', 205, 1700); +INSERT INTO `departments` (`department_id`, `department_name`, `manager_id`, `location_id`) VALUES (120, '财务部门1', NULL, 1700); +INSERT INTO `departments` (`department_id`, `department_name`, `manager_id`, `location_id`) VALUES (130, '企业税务部门', NULL, 1700); +INSERT INTO `departments` (`department_id`, `department_name`, `manager_id`, `location_id`) VALUES (140, '控制和信用部门', NULL, 1700); +INSERT INTO `departments` (`department_id`, `department_name`, `manager_id`, `location_id`) VALUES (150, '股东服务部门', NULL, 1700); +INSERT INTO `departments` (`department_id`, `department_name`, `manager_id`, `location_id`) VALUES (160, '员工福利部门', NULL, 1700); +INSERT INTO `departments` (`department_id`, `department_name`, `manager_id`, `location_id`) VALUES (170, '制造部门', NULL, 1700); +INSERT INTO `departments` (`department_id`, `department_name`, `manager_id`, `location_id`) VALUES (180, '建筑部门', NULL, 1700); +INSERT INTO `departments` (`department_id`, `department_name`, `manager_id`, `location_id`) VALUES (190, '承包部门', NULL, 1700); +INSERT INTO `departments` (`department_id`, `department_name`, `manager_id`, `location_id`) VALUES (200, '运营部', NULL, 1700); +INSERT INTO `departments` (`department_id`, `department_name`, `manager_id`, `location_id`) VALUES (210, '信息技术支持部门', NULL, 1700); +INSERT INTO `departments` (`department_id`, `department_name`, `manager_id`, `location_id`) VALUES (220, '网络运营中心', NULL, 1700); +INSERT INTO `departments` (`department_id`, `department_name`, `manager_id`, `location_id`) VALUES (230, '信息技术帮助台', NULL, 1700); +INSERT INTO `departments` (`department_id`, `department_name`, `manager_id`, `location_id`) VALUES (240, '政府销售部门', NULL, 1700); +INSERT INTO `departments` (`department_id`, `department_name`, `manager_id`, `location_id`) VALUES (250, '零售销售部门', NULL, 1700); +INSERT INTO `departments` (`department_id`, `department_name`, `manager_id`, `location_id`) VALUES (260, '招聘部门', NULL, 1700); +INSERT INTO `departments` (`department_id`, `department_name`, `manager_id`, `location_id`) VALUES (270, '工资单部门', NULL, 1700); +COMMIT; + +-- ---------------------------- +-- Table structure for employees +-- ---------------------------- +DROP TABLE IF EXISTS `employees`; +CREATE TABLE `employees` ( + `employee_id` int NOT NULL DEFAULT '0', + `first_name` varchar(20) DEFAULT NULL, + `last_name` varchar(25) NOT NULL, + `email` varchar(25) NOT NULL, + `phone_number` varchar(20) DEFAULT NULL, + `hire_date` date NOT NULL, + `job_id` varchar(10) NOT NULL, + `salary` double(8,2) DEFAULT NULL, + `commission_pct` double(2,2) DEFAULT NULL, + `manager_id` int DEFAULT NULL, + `department_id` int DEFAULT NULL, + PRIMARY KEY (`employee_id`), + UNIQUE KEY `emp_email_uk` (`email`), + UNIQUE KEY `emp_emp_id_pk` (`employee_id`), + KEY `emp_dept_fk` (`department_id`), + KEY `emp_job_fk` (`job_id`), + KEY `emp_manager_fk` (`manager_id`), + CONSTRAINT `emp_dept_fk` FOREIGN KEY (`department_id`) REFERENCES `departments` (`department_id`), + CONSTRAINT `emp_job_fk` FOREIGN KEY (`job_id`) REFERENCES `jobs` (`job_id`), + CONSTRAINT `emp_manager_fk` FOREIGN KEY (`manager_id`) REFERENCES `employees` (`employee_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; + +-- ---------------------------- +-- Records of employees +-- ---------------------------- +BEGIN; +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (100, '史蒂文', '金', 'SKING', '515.123.4567', '1987-06-17', 'AD_PRES', 24000.00, NULL, NULL, 90); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (101, '尼娜', '科查尔', 'NKOCHHAR', '515.123.4568', '1989-09-21', 'AD_VP', 17000.00, NULL, 100, 90); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (102, '雷克斯', '德哈恩', 'LDEHAAN', '515.123.4569', '1993-01-13', 'AD_VP', 17000.00, NULL, 100, 90); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (103, '亚历山大', '胡诺尔德', 'AHUNOLD', '590.423.4567', '1990-01-03', 'IT_PROG', 9000.00, NULL, 102, 60); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (104, '布鲁斯', '恩斯特', 'BERNST', '590.423.4568', '1991-05-21', 'IT_PROG', 6000.00, NULL, 103, 60); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (105, '大卫', '奥斯汀', 'DAUSTIN', '590.423.4569', '1997-06-25', 'IT_PROG', 4800.00, NULL, 103, 60); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (106, '瓦利', '帕塔巴拉', 'VPATABAL', '590.423.4560', '1998-02-05', 'IT_PROG', 4800.00, NULL, 103, 60); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (107, '黛安娜', '洛伦茨', 'DLORENTZ', '590.423.5567', '1999-02-07', 'IT_PROG', 4200.00, NULL, 103, 60); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (108, '南希', '格林伯格', 'NGREENBE', '515.124.4569', '1994-08-17', 'FI_MGR', 12000.00, NULL, 101, 100); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (109, '丹尼尔', '法维特', 'DFAVIET', '515.124.4169', '1994-08-16', 'FI_ACCOUNT', 9000.00, NULL, 108, 100); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (110, '约翰', '陈', 'JCHEN', '515.124.4269', '1997-09-28', 'FI_ACCOUNT', 8200.00, NULL, 108, 100); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (111, '伊斯梅尔', '斯基亚拉', 'ISCIARRA', '515.124.4369', '1997-09-30', 'FI_ACCOUNT', 7700.00, NULL, 108, 100); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (112, '何塞·曼努埃尔', '乌尔曼', 'JMURMAN', '515.124.4469', '1998-03-07', 'FI_ACCOUNT', 7800.00, NULL, 108, 100); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (113, '路易斯', '波普', 'LPOPP', '515.124.4567', '1999-12-07', 'FI_ACCOUNT', 6900.00, NULL, 108, 100); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (114, '丹', '拉法艾利', 'DRAPHEAL', '515.127.4561', '1994-12-07', 'PU_MAN', 11000.00, NULL, 100, 30); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (115, '亚历山大', '胡', 'AKHOO', '515.127.4562', '1995-05-18', 'PU_CLERK', 3100.00, NULL, 114, 30); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (116, '雪莉', '拜达', 'SBAIDA', '515.127.4563', '1997-12-24', 'PU_CLERK', 2900.00, NULL, 114, 30); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (117, '西加尔', '托比亚斯', 'STOBIAS', '515.127.4564', '1997-07-24', 'PU_CLERK', 2800.00, NULL, 114, 30); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (118, '盖伊', '火室', 'GHIMURO', '515.127.4565', '1998-11-15', 'PU_CLERK', 2600.00, NULL, 114, 30); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (119, '卡伦', '科尔门纳雷斯', 'KCOLMENA', '515.127.4566', '1999-08-10', 'PU_CLERK', 2500.00, NULL, 114, 30); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (120, '马修', '韦斯', 'MWEISS', '650.123.1234', '1996-07-18', 'ST_MAN', 8000.00, NULL, 100, 50); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (121, '亚当', '弗里普', 'AFRIPP', '650.123.2234', '1997-04-10', 'ST_MAN', 8200.00, NULL, 100, 50); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (122, '帕亚姆', '考夫林', 'PKAUFLIN', '650.123.3234', '1995-05-01', 'ST_MAN', 7900.00, NULL, 100, 50); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (123, '珊塔', '沃尔曼', 'SVOLLMAN', '650.123.4234', '1997-10-10', 'ST_MAN', 6500.00, NULL, 100, 50); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (124, '凯文', '莫尔戈斯', 'KMOURGOS', '650.123.5234', '1999-11-16', 'ST_MAN', 5800.00, NULL, 100, 50); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (125, '朱莉娅', '内耶尔', 'JNAYER', '650.124.1214', '1997-07-16', 'ST_CLERK', 3200.00, NULL, 120, 50); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (126, '艾琳', '米基利内尼', 'IMIKKILI', '650.124.1224', '1998-09-28', 'ST_CLERK', 2700.00, NULL, 120, 50); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (127, '詹姆斯', '兰德里', 'JLANDRY', '650.124.1334', '1999-01-14', 'ST_CLERK', 2400.00, NULL, 120, 50); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (128, '史蒂文', '马克尔', 'SMARKLE', '650.124.1434', '2000-03-08', 'ST_CLERK', 2200.00, NULL, 120, 50); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (129, '劳拉', '比索特', 'LBISSOT', '650.124.5234', '1997-08-20', 'ST_CLERK', 3300.00, NULL, 121, 50); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (130, '莫兹', '阿特金森', 'MATKINSO', '650.124.6234', '1997-10-30', 'ST_CLERK', 2800.00, NULL, 121, 50); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (131, '詹姆斯', '马洛', 'JAMRLOW', '650.124.7234', '1997-02-16', 'ST_CLERK', 2500.00, NULL, 121, 50); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (132, 'TJ', '奥尔森', 'TJOLSON', '650.124.8234', '1999-04-10', 'ST_CLERK', 2100.00, NULL, 121, 50); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (133, '贾森', '马林', 'JMALLIN', '650.127.1934', '1996-06-14', 'ST_CLERK', 3300.00, NULL, 122, 50); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (134, '迈克尔', '罗杰斯', 'MROGERS', '650.127.1834', '1998-08-26', 'ST_CLERK', 2900.00, NULL, 122, 50); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (135, '基', '吉', 'KGEE', '650.127.1734', '1999-12-12', 'ST_CLERK', 2400.00, NULL, 122, 50); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (136, '海泽尔', '菲尔坦克', 'HPHILTAN', '650.127.1634', '2000-02-06', 'ST_CLERK', 2200.00, NULL, 122, 50); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (137, '伦斯克', '拉德维格', 'RLADWIG', '650.121.1234', '1995-07-14', 'ST_CLERK', 3600.00, NULL, 123, 50); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (138, '斯蒂芬', '斯泰尔斯', 'SSTILES', '650.121.2034', '1997-10-26', 'ST_CLERK', 3200.00, NULL, 123, 50); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (139, '约翰', '西奥', 'JSEO', '650.121.2019', '1998-02-12', 'ST_CLERK', 2700.00, NULL, 123, 50); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (140, '乔舒亚', '帕特尔', 'JPATEL', '650.121.1834', '1998-04-06', 'ST_CLERK', 2500.00, NULL, 123, 50); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (141, '特蕾娜', '拉杰斯', 'TRAJS', '650.121.8009', '1995-10-17', 'ST_CLERK', 3500.00, NULL, 124, 50); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (142, '柯蒂斯', '戴维斯', 'CDAVIES', '650.121.2994', '1997-01-29', 'ST_CLERK', 3100.00, NULL, 124, 50); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (143, '兰德尔', '马托斯', 'RMATOS', '650.121.2874', '1998-03-15', 'ST_CLERK', 2600.00, NULL, 124, 50); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (144, '彼得', '瓦加斯', 'PVARGAS', '650.121.2004', '1998-07-09', 'ST_CLERK', 2500.00, NULL, 124, 50); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (145, '约翰', '罗素', 'JRUSSEL', '011.44.1344.429268', '1996-10-01', 'SA_MAN', 14000.00, 0.40, 100, 80); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (146, '卡伦', '帕特纳斯', 'KPARTNER', '011.44.1344.467268', '1997-01-05', 'SA_MAN', 13500.00, 0.30, 100, 80); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (147, '阿尔贝托', '埃拉苏里斯', 'AERRAZUR', '011.44.1344.429278', '1997-03-10', 'SA_MAN', 12000.00, 0.30, 100, 80); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (148, '杰拉德', '坎布劳特', 'GCAMBRAU', '011.44.1344.619268', '1999-10-15', 'SA_MAN', 11000.00, 0.30, 100, 80); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (149, '埃莱妮', '兹洛特基', 'EZLOTKEY', '011.44.1344.429018', '2000-01-29', 'SA_MAN', 10500.00, 0.20, 100, 80); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (150, '彼得', '塔克', 'PTUCKER', '011.44.1344.129268', '1997-01-30', 'SA_REP', 10000.00, 0.30, 145, 80); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (151, '大卫', '伯恩斯坦', 'DBERNSTE', '011.44.1344.345268', '1997-03-24', 'SA_REP', 9500.00, 0.25, 145, 80); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (152, '彼得', '霍尔', 'PHALL', '011.44.1344.478968', '1997-08-20', 'SA_REP', 9000.00, 0.25, 145, 80); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (153, '克里斯托弗', '奥尔森', 'COLSEN', '011.44.1344.498718', '1998-03-30', 'SA_REP', 8000.00, 0.20, 145, 80); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (154, '娜妮特', '坎布劳特', 'NCAMBRAU', '011.44.1344.987668', '1998-12-09', 'SA_REP', 7500.00, 0.20, 145, 80); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (155, '奥利弗', '图沃尔特', 'OTUVAULT', '011.44.1344.486508', '1999-11-23', 'SA_REP', 7000.00, 0.15, 145, 80); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (156, '詹妮特', '金', 'JKING', '011.44.1345.429268', '1996-01-30', 'SA_REP', 10000.00, 0.35, 146, 80); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (157, '帕特里克', '萨利', 'PSULLY', '011.44.1345.929268', '1996-03-04', 'SA_REP', 9500.00, 0.35, 146, 80); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (158, '艾伦', '麦克尤恩', 'AMCEWEN', '011.44.1345.829268', '1996-08-01', 'SA_REP', 9000.00, 0.35, 146, 80); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (159, '林赛', '史密斯', 'LSMITH', '011.44.1345.729268', '1997-03-10', 'SA_REP', 8000.00, 0.30, 146, 80); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (160, '路易斯', '多兰', 'LDORAN', '011.44.1345.629268', '1997-12-15', 'SA_REP', 7500.00, 0.30, 146, 80); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (161, '萨拉特', '肖尔', 'SSEWALL', '011.44.1345.529268', '1998-11-03', 'SA_REP', 7000.00, 0.25, 146, 80); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (162, '克拉拉', '维什尼', 'CVISHNEY', '011.44.1346.129268', '1997-11-11', 'SA_REP', 10500.00, 0.25, 147, 80); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (163, '丹妮尔', '格林', 'DGREENE', '011.44.1346.229268', '1999-03-19', 'SA_REP', 9500.00, 0.15, 147, 80); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (164, '玛蒂亚', '马文斯', 'MMARVINS', '011.44.1346.329268', '2000-01-24', 'SA_REP', 7200.00, 0.10, 147, 80); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (165, '大卫', '李', 'DLEE', '011.44.1346.529268', '2000-02-23', 'SA_REP', 6800.00, 0.10, 147, 80); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (166, '桑达尔', '安迪', 'SANDE', '011.44.1346.629268', '2000-03-24', 'SA_REP', 6400.00, 0.10, 147, 80); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (167, '阿米特', '班达', 'ABANDA', '011.44.1346.729268', '2000-04-21', 'SA_REP', 6200.00, 0.10, 147, 80); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (168, '丽莎', '奥泽尔', 'LOZER', '011.44.1343.929268', '1997-03-11', 'SA_REP', 11500.00, 0.25, 148, 80); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (169, '哈里森', '布鲁姆', 'HBLOOM', '011.44.1343.829268', '1998-03-23', 'SA_REP', 10000.00, 0.20, 148, 80); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (170, '泰勒', '福克斯', 'TFOX', '011.44.1343.729268', '1998-01-24', 'SA_REP', 9600.00, 0.20, 148, 80); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (171, '威廉', '史密斯', 'WSMITH', '011.44.1343.629268', '1999-02-23', 'SA_REP', 7400.00, 0.15, 148, 80); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (172, '伊丽莎白', '贝茨', 'EBATES', '011.44.1343.529268', '1999-03-24', 'SA_REP', 7300.00, 0.15, 148, 80); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (173, '桑迪塔', '库马尔', 'SKUMAR', '011.44.1343.329268', '2000-04-21', 'SA_REP', 6100.00, 0.10, 148, 80); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (174, '艾伦', '阿贝尔', 'EABEL', '011.44.1644.429267', '1996-05-11', 'SA_REP', 11000.00, 0.30, 149, 80); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (175, '阿莉莎', '哈顿', 'AHUTTON', '011.44.1644.429266', '1997-03-19', 'SA_REP', 8800.00, 0.25, 149, 80); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (176, '乔纳森', '泰勒', 'JTAYLOR', '011.44.1644.429265', '1998-03-24', 'SA_REP', 8600.00, 0.20, 149, 80); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (177, '杰克', '利文斯顿', 'JLIVINGS', '011.44.1644.429264', '1998-04-23', 'SA_REP', 8400.00, 0.20, 149, 80); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (178, '金柏莉', '格兰特', 'KGRANT', '011.44.1644.429263', '1999-05-24', 'SA_REP', 7000.00, 0.15, 149, NULL); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (179, '查尔斯', '约翰逊', 'CJOHNSON', '011.44.1644.429262', '2000-01-04', 'SA_REP', 6200.00, 0.10, 149, 80); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (180, '温斯顿', '泰勒', 'WTAYLOR', '650.507.9876', '1998-01-24', 'SH_CLERK', 3200.00, NULL, 120, 50); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (181, '简', '弗勒尔', 'JFLEAUR', '650.507.9877', '1998-02-23', 'SH_CLERK', 3100.00, NULL, 120, 50); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (182, '玛莎', '沙利文', 'MSULLIVA', '650.507.9878', '1999-06-21', 'SH_CLERK', 2500.00, NULL, 120, 50); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (183, '吉拉德', '格奥尼', 'GGEONI', '650.507.9879', '2000-02-03', 'SH_CLERK', 2800.00, NULL, 120, 50); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (184, '南迪塔', '萨尔钦德', 'NSARCHAN', '650.509.1876', '1996-01-27', 'SH_CLERK', 4200.00, NULL, 121, 50); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (185, '亚历克西斯', '布尔', 'ABULL', '650.509.2876', '1997-02-20', 'SH_CLERK', 4100.00, NULL, 121, 50); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (186, '朱莉娅', '戴林格', 'JDELLING', '650.509.3876', '1998-06-24', 'SH_CLERK', 3400.00, NULL, 121, 50); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (187, '安东尼', '卡布里奥', 'ACABRIO', '650.509.4876', '1999-02-07', 'SH_CLERK', 3000.00, NULL, 121, 50); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (188, '凯莉', '钟', 'KCHUNG', '650.505.1876', '1997-06-14', 'SH_CLERK', 3800.00, NULL, 122, 50); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (189, '詹妮弗', '迪利', 'JDILLY', '650.505.2876', '1997-08-13', 'SH_CLERK', 3600.00, NULL, 122, 50); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (190, '蒂莫西', '盖茨', 'TGATES', '650.505.3876', '1998-07-11', 'SH_CLERK', 2900.00, NULL, 122, 50); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (191, '兰达尔', '珀金斯', 'RPERKINS', '650.505.4876', '1999-12-19', 'SH_CLERK', 2500.00, NULL, 122, 50); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (192, '萨拉', '贝尔', 'SBELL', '650.501.1876', '1996-02-04', 'SH_CLERK', 4000.00, NULL, 123, 50); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (193, '布里特尼', '埃弗雷特', 'BEVERETT', '650.501.2876', '1997-03-03', 'SH_CLERK', 3900.00, NULL, 123, 50); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (194, '塞缪尔', '麦凯恩', 'SMCCAIN', '650.501.3876', '1998-07-01', 'SH_CLERK', 3200.00, NULL, 123, 50); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (195, '范斯', '琼斯', 'VJONES', '650.501.4876', '1999-03-17', 'SH_CLERK', 2800.00, NULL, 123, 50); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (196, '阿兰娜', '沃尔什', 'AWALSH', '650.507.9811', '1998-04-24', 'SH_CLERK', 3100.00, NULL, 124, 50); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (197, '凯文', '费尼', 'KFEENEY', '650.507.9822', '1998-05-23', 'SH_CLERK', 3000.00, NULL, 124, 50); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (198, '唐纳德', '奥康奈尔', 'DOCONNEL', '650.507.9833', '1999-06-21', 'SH_CLERK', 2600.00, NULL, 124, 50); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (199, '道格拉斯', '格兰特', 'DGRANT', '650.507.9844', '2000-01-13', 'SH_CLERK', 2600.00, NULL, 124, 50); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (200, '詹妮弗', '韦伦', 'JWHALEN', '515.123.4444', '1987-09-17', 'AD_ASST', 4400.00, NULL, 101, 10); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (201, '迈克尔', '哈滕斯坦', 'MHARTSTE', '515.123.5555', '1996-02-17', 'MK_MAN', 13000.00, NULL, 100, 20); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (202, '帕特', '费伊', 'PFAY', '603.123.6666', '1997-08-17', 'MK_REP', 6000.00, NULL, 201, 20); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (203, '苏珊', '马夫里斯', 'SMAVRIS', '515.123.7777', '1994-06-07', 'HR_REP', 6500.00, NULL, 101, 40); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (204, '赫尔曼', '拜尔', 'HBAER', '515.123.8888', '1994-06-07', 'PR_REP', 10000.00, NULL, 101, 70); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (205, '谢莉', '希金斯', 'SHIGGINS', '515.123.8080', '1994-06-07', 'AC_MGR', 12000.00, NULL, 101, 110); +INSERT INTO `employees` (`employee_id`, `first_name`, `last_name`, `email`, `phone_number`, `hire_date`, `job_id`, `salary`, `commission_pct`, `manager_id`, `department_id`) VALUES (206, '威廉', '吉茨', 'WGIETZ', '515.123.8181', '1994-06-07', 'AC_ACCOUNT', 8300.00, NULL, 205, 110); +COMMIT; + +-- ---------------------------- +-- Table structure for job_grades +-- ---------------------------- +DROP TABLE IF EXISTS `job_grades`; +CREATE TABLE `job_grades` ( + `grade_level` varchar(3) DEFAULT NULL, + `lowest_sal` int DEFAULT NULL, + `highest_sal` int DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; + +-- ---------------------------- +-- Records of job_grades +-- ---------------------------- +BEGIN; +INSERT INTO `job_grades` (`grade_level`, `lowest_sal`, `highest_sal`) VALUES ('A', 1000, 2999); +INSERT INTO `job_grades` (`grade_level`, `lowest_sal`, `highest_sal`) VALUES ('B', 3000, 5999); +INSERT INTO `job_grades` (`grade_level`, `lowest_sal`, `highest_sal`) VALUES ('C', 6000, 9999); +INSERT INTO `job_grades` (`grade_level`, `lowest_sal`, `highest_sal`) VALUES ('D', 10000, 14999); +INSERT INTO `job_grades` (`grade_level`, `lowest_sal`, `highest_sal`) VALUES ('E', 15000, 24999); +INSERT INTO `job_grades` (`grade_level`, `lowest_sal`, `highest_sal`) VALUES ('F', 25000, 40000); +COMMIT; + +-- ---------------------------- +-- Table structure for job_history +-- ---------------------------- +DROP TABLE IF EXISTS `job_history`; +CREATE TABLE `job_history` ( + `employee_id` int NOT NULL, + `start_date` date NOT NULL, + `end_date` date NOT NULL, + `job_id` varchar(10) NOT NULL, + `department_id` int DEFAULT NULL, + PRIMARY KEY (`employee_id`,`start_date`), + UNIQUE KEY `jhist_emp_id_st_date_pk` (`employee_id`,`start_date`), + KEY `jhist_job_fk` (`job_id`), + KEY `jhist_dept_fk` (`department_id`), + CONSTRAINT `jhist_dept_fk` FOREIGN KEY (`department_id`) REFERENCES `departments` (`department_id`), + CONSTRAINT `jhist_emp_fk` FOREIGN KEY (`employee_id`) REFERENCES `employees` (`employee_id`), + CONSTRAINT `jhist_job_fk` FOREIGN KEY (`job_id`) REFERENCES `jobs` (`job_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; + +-- ---------------------------- +-- Records of job_history +-- ---------------------------- +BEGIN; +INSERT INTO `job_history` (`employee_id`, `start_date`, `end_date`, `job_id`, `department_id`) VALUES (101, '1989-09-21', '1993-10-27', 'AC_ACCOUNT', 110); +INSERT INTO `job_history` (`employee_id`, `start_date`, `end_date`, `job_id`, `department_id`) VALUES (101, '1993-10-28', '1997-03-15', 'AC_MGR', 110); +INSERT INTO `job_history` (`employee_id`, `start_date`, `end_date`, `job_id`, `department_id`) VALUES (102, '1993-01-13', '1998-07-24', 'IT_PROG', 60); +INSERT INTO `job_history` (`employee_id`, `start_date`, `end_date`, `job_id`, `department_id`) VALUES (114, '1998-03-24', '1999-12-31', 'ST_CLERK', 50); +INSERT INTO `job_history` (`employee_id`, `start_date`, `end_date`, `job_id`, `department_id`) VALUES (122, '1999-01-01', '1999-12-31', 'ST_CLERK', 50); +INSERT INTO `job_history` (`employee_id`, `start_date`, `end_date`, `job_id`, `department_id`) VALUES (176, '1998-03-24', '1998-12-31', 'SA_REP', 80); +INSERT INTO `job_history` (`employee_id`, `start_date`, `end_date`, `job_id`, `department_id`) VALUES (176, '1999-01-01', '1999-12-31', 'SA_MAN', 80); +INSERT INTO `job_history` (`employee_id`, `start_date`, `end_date`, `job_id`, `department_id`) VALUES (200, '1987-09-17', '1993-06-17', 'AD_ASST', 90); +INSERT INTO `job_history` (`employee_id`, `start_date`, `end_date`, `job_id`, `department_id`) VALUES (200, '1994-07-01', '1998-12-31', 'AC_ACCOUNT', 90); +INSERT INTO `job_history` (`employee_id`, `start_date`, `end_date`, `job_id`, `department_id`) VALUES (201, '1996-02-17', '1999-12-19', 'MK_REP', 20); +COMMIT; + +-- ---------------------------- +-- Table structure for jobs +-- ---------------------------- +DROP TABLE IF EXISTS `jobs`; +CREATE TABLE `jobs` ( + `job_id` varchar(10) NOT NULL DEFAULT '', + `job_title` varchar(35) NOT NULL, + `min_salary` int DEFAULT NULL, + `max_salary` int DEFAULT NULL, + PRIMARY KEY (`job_id`), + UNIQUE KEY `job_id_pk` (`job_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; + +-- ---------------------------- +-- Records of jobs +-- ---------------------------- +BEGIN; +INSERT INTO `jobs` (`job_id`, `job_title`, `min_salary`, `max_salary`) VALUES ('AC_ACCOUNT', '公共会计师', 4200, 9000); +INSERT INTO `jobs` (`job_id`, `job_title`, `min_salary`, `max_salary`) VALUES ('AC_MGR', '会计经理', 8200, 16000); +INSERT INTO `jobs` (`job_id`, `job_title`, `min_salary`, `max_salary`) VALUES ('AD_ASST', '行政助理', 3000, 6000); +INSERT INTO `jobs` (`job_id`, `job_title`, `min_salary`, `max_salary`) VALUES ('AD_PRES', '总裁', 20000, 40000); +INSERT INTO `jobs` (`job_id`, `job_title`, `min_salary`, `max_salary`) VALUES ('AD_VP', '行政副总裁', 15000, 30000); +INSERT INTO `jobs` (`job_id`, `job_title`, `min_salary`, `max_salary`) VALUES ('FI_ACCOUNT', '会计', 4200, 9000); +INSERT INTO `jobs` (`job_id`, `job_title`, `min_salary`, `max_salary`) VALUES ('FI_MGR', '财务经理', 8200, 16000); +INSERT INTO `jobs` (`job_id`, `job_title`, `min_salary`, `max_salary`) VALUES ('HR_REP', '人力资源代表', 4000, 9000); +INSERT INTO `jobs` (`job_id`, `job_title`, `min_salary`, `max_salary`) VALUES ('IT_PROG', '程序员', 4000, 10000); +INSERT INTO `jobs` (`job_id`, `job_title`, `min_salary`, `max_salary`) VALUES ('MK_MAN', '市场营销经理', 9000, 15000); +INSERT INTO `jobs` (`job_id`, `job_title`, `min_salary`, `max_salary`) VALUES ('MK_REP', '市场营销代表', 4000, 9000); +INSERT INTO `jobs` (`job_id`, `job_title`, `min_salary`, `max_salary`) VALUES ('PR_REP', '公共关系代表', 4500, 10500); +INSERT INTO `jobs` (`job_id`, `job_title`, `min_salary`, `max_salary`) VALUES ('PU_CLERK', '采购文员', 2500, 5500); +INSERT INTO `jobs` (`job_id`, `job_title`, `min_salary`, `max_salary`) VALUES ('PU_MAN', '采购经理', 8000, 15000); +INSERT INTO `jobs` (`job_id`, `job_title`, `min_salary`, `max_salary`) VALUES ('SA_MAN', '销售经理', 10000, 20000); +INSERT INTO `jobs` (`job_id`, `job_title`, `min_salary`, `max_salary`) VALUES ('SA_REP', '销售代表', 6000, 12000); +INSERT INTO `jobs` (`job_id`, `job_title`, `min_salary`, `max_salary`) VALUES ('SH_CLERK', '发货文员', 2500, 5500); +INSERT INTO `jobs` (`job_id`, `job_title`, `min_salary`, `max_salary`) VALUES ('ST_CLERK', '库存文员', 2000, 5000); +INSERT INTO `jobs` (`job_id`, `job_title`, `min_salary`, `max_salary`) VALUES ('ST_MAN', '库存经理', 5500, 8500); +COMMIT; + +-- ---------------------------- +-- Table structure for locations +-- ---------------------------- +DROP TABLE IF EXISTS `locations`; +CREATE TABLE `locations` ( + `location_id` int NOT NULL DEFAULT '0', + `street_address` varchar(40) DEFAULT NULL, + `postal_code` varchar(12) DEFAULT NULL, + `city` varchar(30) NOT NULL, + `state_province` varchar(25) DEFAULT NULL, + `country_id` char(2) DEFAULT NULL, + PRIMARY KEY (`location_id`), + UNIQUE KEY `loc_id_pk` (`location_id`), + KEY `loc_c_id_fk` (`country_id`), + CONSTRAINT `loc_c_id_fk` FOREIGN KEY (`country_id`) REFERENCES `countries` (`country_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; + +-- ---------------------------- +-- Records of locations +-- ---------------------------- +BEGIN; +INSERT INTO `locations` (`location_id`, `street_address`, `postal_code`, `city`, `state_province`, `country_id`) VALUES (1000, '1297 Via Cola di Rie', '00989', '罗马', NULL, 'IT'); +INSERT INTO `locations` (`location_id`, `street_address`, `postal_code`, `city`, `state_province`, `country_id`) VALUES (1100, '93091 Calle della Testa', '10934', '威尼斯', NULL, 'IT'); +INSERT INTO `locations` (`location_id`, `street_address`, `postal_code`, `city`, `state_province`, `country_id`) VALUES (1200, '2017 Shinjuku-ku', '1689', '东京', '东京都', 'JP'); +INSERT INTO `locations` (`location_id`, `street_address`, `postal_code`, `city`, `state_province`, `country_id`) VALUES (1300, '9450 Kamiya-cho', '6823', '广岛', NULL, 'JP'); +INSERT INTO `locations` (`location_id`, `street_address`, `postal_code`, `city`, `state_province`, `country_id`) VALUES (1400, '2014 Jabberwocky Rd', '26192', '南湖', '德克萨斯', 'US'); +INSERT INTO `locations` (`location_id`, `street_address`, `postal_code`, `city`, `state_province`, `country_id`) VALUES (1500, '2011 Interiors Blvd', '99236', '南旧金山', '加利福尼亚', 'US'); +INSERT INTO `locations` (`location_id`, `street_address`, `postal_code`, `city`, `state_province`, `country_id`) VALUES (1600, '2007 Zagora St', '50090', '南布朗斯维克', '新泽西', 'US'); +INSERT INTO `locations` (`location_id`, `street_address`, `postal_code`, `city`, `state_province`, `country_id`) VALUES (1700, '2004 Charade Rd', '98199', '西雅图', '华盛顿', 'US'); +INSERT INTO `locations` (`location_id`, `street_address`, `postal_code`, `city`, `state_province`, `country_id`) VALUES (1800, '147 Spadina Ave', 'M5V 2L7', '多伦多', '安大略', 'CA'); +INSERT INTO `locations` (`location_id`, `street_address`, `postal_code`, `city`, `state_province`, `country_id`) VALUES (1900, '6092 Boxwood St', 'YSW 9T2', '怀特霍斯', '育空', 'CA'); +INSERT INTO `locations` (`location_id`, `street_address`, `postal_code`, `city`, `state_province`, `country_id`) VALUES (2000, '40-5-12 Laogianggen', '190518', '北京', NULL, 'CN'); +INSERT INTO `locations` (`location_id`, `street_address`, `postal_code`, `city`, `state_province`, `country_id`) VALUES (2100, '1298 Vileparle (E)', '490231', '孟买', '马哈拉施特拉邦', 'IN'); +INSERT INTO `locations` (`location_id`, `street_address`, `postal_code`, `city`, `state_province`, `country_id`) VALUES (2200, '12-98 Victoria Street', '2901', '悉尼', '新南威尔士', 'AU'); +INSERT INTO `locations` (`location_id`, `street_address`, `postal_code`, `city`, `state_province`, `country_id`) VALUES (2300, '198 Clementi North', '540198', '新加坡', NULL, 'SG'); +INSERT INTO `locations` (`location_id`, `street_address`, `postal_code`, `city`, `state_province`, `country_id`) VALUES (2400, '8204 Arthur St', NULL, '伦敦', NULL, 'UK'); +INSERT INTO `locations` (`location_id`, `street_address`, `postal_code`, `city`, `state_province`, `country_id`) VALUES (2500, 'Magdalen Centre, The Oxford Science Park', 'OX9 9ZB', '牛津', '牛津', 'UK'); +INSERT INTO `locations` (`location_id`, `street_address`, `postal_code`, `city`, `state_province`, `country_id`) VALUES (2600, '9702 Chester Road', '09629850293', '斯特雷福德', '曼彻斯特', 'UK'); +INSERT INTO `locations` (`location_id`, `street_address`, `postal_code`, `city`, `state_province`, `country_id`) VALUES (2700, 'Schwanthalerstr. 7031', '80925', '慕尼黑', '巴伐利亚', 'DE'); +INSERT INTO `locations` (`location_id`, `street_address`, `postal_code`, `city`, `state_province`, `country_id`) VALUES (2800, 'Rua Frei Caneca 1360 ', '01307-002', '圣保罗', '圣保罗', 'BR'); +INSERT INTO `locations` (`location_id`, `street_address`, `postal_code`, `city`, `state_province`, `country_id`) VALUES (2900, '20 Rue des Corps-Saints', '1730', '日内瓦', '日内瓦', 'CH'); +INSERT INTO `locations` (`location_id`, `street_address`, `postal_code`, `city`, `state_province`, `country_id`) VALUES (3000, 'Murtenstrasse 921', '3095', '伯尔尼', 'BE', 'CH'); +INSERT INTO `locations` (`location_id`, `street_address`, `postal_code`, `city`, `state_province`, `country_id`) VALUES (3100, 'Pieter Breughelstraat 837', '3029SK', '乌得勒支', '乌得勒支', 'NL'); +INSERT INTO `locations` (`location_id`, `street_address`, `postal_code`, `city`, `state_province`, `country_id`) VALUES (3200, 'Mariano Escobedo 9991', '11932', '墨西哥城', '联邦区', 'MX'); +COMMIT; + +-- ---------------------------- +-- Table structure for order +-- ---------------------------- +DROP TABLE IF EXISTS `order`; +CREATE TABLE `order` ( + `order_id` int DEFAULT NULL, + `order_name` varchar(15) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; + +-- ---------------------------- +-- Records of order +-- ---------------------------- +BEGIN; +INSERT INTO `order` (`order_id`, `order_name`) VALUES (1, 'shkstart'); +INSERT INTO `order` (`order_id`, `order_name`) VALUES (2, 'tomcat'); +INSERT INTO `order` (`order_id`, `order_name`) VALUES (3, 'dubbo'); +COMMIT; + +-- ---------------------------- +-- Table structure for regions +-- ---------------------------- +DROP TABLE IF EXISTS `regions`; +CREATE TABLE `regions` ( + `region_id` int NOT NULL, + `region_name` varchar(25) DEFAULT NULL, + PRIMARY KEY (`region_id`), + UNIQUE KEY `reg_id_pk` (`region_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; + +-- ---------------------------- +-- Records of regions +-- ---------------------------- +BEGIN; +INSERT INTO `regions` (`region_id`, `region_name`) VALUES (1, '欧洲'); +INSERT INTO `regions` (`region_id`, `region_name`) VALUES (2, '美洲'); +INSERT INTO `regions` (`region_id`, `region_name`) VALUES (3, '亚洲'); +INSERT INTO `regions` (`region_id`, `region_name`) VALUES (4, '中东和非洲'); +COMMIT; + +-- ---------------------------- +-- View structure for emp_details_view +-- ---------------------------- +DROP VIEW IF EXISTS `emp_details_view`; +CREATE ALGORITHM = UNDEFINED SQL SECURITY DEFINER VIEW `emp_details_view` AS select `e`.`employee_id` AS `employee_id`,`e`.`job_id` AS `job_id`,`e`.`manager_id` AS `manager_id`,`e`.`department_id` AS `department_id`,`d`.`location_id` AS `location_id`,`l`.`country_id` AS `country_id`,`e`.`first_name` AS `first_name`,`e`.`last_name` AS `last_name`,`e`.`salary` AS `salary`,`e`.`commission_pct` AS `commission_pct`,`d`.`department_name` AS `department_name`,`j`.`job_title` AS `job_title`,`l`.`city` AS `city`,`l`.`state_province` AS `state_province`,`c`.`country_name` AS `country_name`,`r`.`region_name` AS `region_name` from (((((`employees` `e` join `departments` `d`) join `jobs` `j`) join `locations` `l`) join `countries` `c`) join `regions` `r`) where ((`e`.`department_id` = `d`.`department_id`) and (`d`.`location_id` = `l`.`location_id`) and (`l`.`country_id` = `c`.`country_id`) and (`c`.`region_id` = `r`.`region_id`) and (`j`.`job_id` = `e`.`job_id`)); + +SET FOREIGN_KEY_CHECKS = 1; + + + + + + +#第03章_基本的SELECT语句的课后练习 + +# 1.查询所有员工12个月的工资总和,并起别名为工资总和 +#理解1:计算12月的基本工资 + select sum(salary * 12) 工资总和 from employees ; + +#理解2:计算12月的基本工资和奖金 +# ifnull(原值,新值) 判断一个原值是否为null,如果原值是null,就用一个新值代替 + select sum(salary * 12) + sum(salary * 12 * commission_pct) 实发工资 from employees; + select sum(salary * 12 + salary * 12 * ifnull(commission_pct,0)) 实发工资 from employees; + +# 2.查询employees表中去除重复的job_id以后的数据 +#去除重复 distinct + select distinct(job_id) from employees; + +# 3.查询工资大于12000的员工姓名和工资 + select first_name 姓名,salary 工资 from employees where salary > 12000; + +# 4.查询员工号为176的员工的姓名和部门号 + select first_name 姓名,department_id 部门号 from employees where employee_id = 176; + +# 5.显示表 departments 的结构,并查询其中的全部数据 + desc departments; + select * from departments; + + + +# 第04章_运算符课后练习 +# 1.选择工资不在5000到12000的员工的姓名和工资 + select first_name 姓名,salary 工资 from employees where salary not between 5000 and 12000; + +# 2.选择在20或50号部门工作的员工姓名和部门号 + select first_name 姓名,department_id 部门号 from employees where department_id in(20,50); + +# 3.选择公司中没有管理者的员工姓名及job_id + select first_name 姓名,job_id from employees where manager_id is null; + +# 4.选择公司中有奖金的员工姓名,奖金和奖金级别 + select first_name 姓名,e.salary*commission_pct 奖金,grade_level 奖金级别 from employees e left join job_grades j on e.salary*commission_pct between j.lowest_sal and j.highest_sal where commission_pct is not null; + +# 5.选择员工姓名的第三个字是 尔 的员工姓名 + select first_name 姓名 from employees where first_name like '__尔'; + +# 6.选择姓名中有 特 字和 尔 字的员工姓名 + select * from employees where last_name like '%特%' and last_name like '%尔%' + +# 7.显示出表 employees 表中 first_name 以 '尔'结尾的员工信息 + select * from employees where first_name like '%尔'; + +# 8.显示出表 employees 部门编号在 80-100 之间的姓名、工种 + select first_name 姓名,job_title 工种 from employees e left join jobs j on e.job_id=j.job_id where department_id between 80 and 100; + +# 9.显示出表 employees 的 manager_id 是 100,101,108 的员工姓名、工资、管理者id + select first_name 员工姓名,salary 工资,manager_id 管理者id from employees where manager_id in(100,101,108) + + + + +#第05章_排序与分页的课后练习 + +#1. 查询员工的姓名和部门号和年薪,按年薪降序显示 +-- order by 年薪 asc/desc + select first_name 姓名,department_id 部门号,(salary * 12) 年薪 from employees order by 年薪 desc; + +#2. 选择工资不在 8000 到 17000 的员工的姓名和工资,按工资降序,显示第21到40位置的数据 + select * from employees where salary not between 8000 and 17000 order by salary desc limit 21,19; + +#3. 查询邮箱中包含 e 的员工信息,并先按邮箱的字节数降序,再按部门号升序 + select * from employees where email like '%e%' order by char_length(email) desc,department_id; + + + + +# 第06章_多表查询的课后练习 + +# 1.显示所有员工的姓名,部门号和部门名称。 + select first_name 姓名,e.job_id 部门号,job_title 部门名称 from employees e,jobs j where e.job_id=j.job_id + +# 2.查询90号部门员工的job_id和90号部门的location_id + select job_id,location_id from employees e,departments d where e.department_id = d.department_id and e.department_id = 90; + +# 3.选择所有 有奖金的员工 的 last_name , department_name , location_id , city + select last_name ,department_name ,d.location_id ,city + from employees e,departments d,locations l + where e.department_id = d.department_id and d.location_id = l.location_id and commission_pct is not null; + + +# 4.选择city在 多伦多 工作的员工的 last_name , job_id , department_id , department_name + + #子查询 + select last_name ,job_id ,b.department_id ,department_name from employees e, + (select department_id ,department_name from departments where location_id = + (select location_id from locations where city = '多伦多')) b where e.department_id=b.department_id; + + #连表查 + select last_name ,job_id ,d.department_id ,department_name + from locations l ,departments d ,employees e + where l.location_id = d.location_id and d.department_id = e.department_id and city = '多伦多'; + + +#sql92语法(自然连接): + +# 5.查询行政部门员工的部门名称、部门地址、姓名、工作、工资 + #select * from locations join departments join employees where department_name = '行政部'; + select d.department_name 部门名称,l.street_address 部门地址,e.first_name 姓名,j.job_title 工作,e.salary 工资 from locations l + left join departments d on l.location_id = d.location_id + left join employees e on d.department_id = e.department_id + right join jobs j on e.job_id = j.job_id where d.department_name = '行政部'; + +# 6.显示所有员工的姓名,员工号,以及他的管理者的姓名和员工号,结果类似于下面的格式 +-- 员工姓名 员工编号 上级姓名 上级的员工编号 +-- 德哈恩 102 金 100 + select e1.last_name 员工姓名,e1.employee_id 员工编号,e2.last_name 上级姓名,e2.employee_id 上级的员工编号 from employees e1,employees e2 where e1.manager_id =e2.employee_id + +# 7.查询哪些部门没有员工 + select department_name 部门名称 from departments d left join employees e on d.department_id = e.department_id where employee_id is null; + +# 8. 查询哪个城市没有部门 + select city 没有部门的城市 from locations where location_id not in + (select distinct(location_id) from departments); + +# 9. 查询部门名为 销售部 或 信息技术部 的员工信息 + select * from employees where department_id in + (select department_id from departments where department_name in('销售部','信息技术部')); + + + + +# 第08章_聚合函数的课后练习 + +#2.查询公司员工工资的最大值,最小值,平均值,总和 + select max(salary) 最大值,min(salary) 最小值,avg(salary) 平均值,sum(salary) 总和 from employees ; + +#3.查询各job_id的员工工资的最大值,最小值,平均值,总和 + select j.job_id, max(salary) 最大值,min(salary) 最小值,avg(salary) 平均值,sum(salary) 总和 + from jobs j left join employees e on j.job_id = e.job_id group by j.job_id; + +#4.选择各个job_id的员工人数 + select j.job_id,count(j.job_id) from jobs j left join employees e on j.job_id = e.job_id group by j.job_id; + +# 5.查询员工最高工资和最低工资的差距 + select max(salary)-min(salary) 最高工资和最低工资的差距 from employees ; + +# 6.查询各个管理者 手下员工的最低工资,其中最低工资不能低于6000,没有管理者的员工不计算在内 + select e1.manager_id,min(e1.salary) 最低工资 + from employees e1 right join employees e2 on e1.manager_id = e2.employee_id + where e1.salary >6000 group by e1.manager_id + +# 7.查询所有部门的名字,location_id,员工数量和平均工资,并按平均工资降序 + select d.department_name 部门名,d.location_id,count(e.department_id) 员工数量,avg(e.salary) 平均工资 + from employees e right join departments d on e.department_id = d.department_id + group by d.department_id order by 平均工资 desc + +# 8.查询每个工种、每个部门的部门名、工种名和最低工资 + + select d.department_name 部门名,j.job_title 工种名,min(e.salary) 最低工资 from jobs j right join employees e on j.job_id = e.job_id left join departments d on e.department_id = d.department_id group by j.job_id,d.department_id; + + + +# 第09章_子查询的课后练习 + +#1.查询和 兹洛特基 相同部门的员工姓名和工资 + select last_name 员工姓名,salary 工资 from employees where department_id = + (select department_id from employees where last_name = '兹洛特基'); + +#2.查询工资比公司平均工资高的员工的员工号,姓名和工资。 + #select l.location_id, avg(e.salary) 平均工资 from locations l right join departments d on l.location_id = d.location_id left join employees e on d.department_id = e.department_id group by l.location_id; + + select employee_id,first_name,salary from employees where salary>(select avg(salary) from employees); + +#3.选择工资大于所有JOB_ID = 'SA_MAN'的员工的工资的员工的last_name, job_id, salary + select last_name, job_id, salary from employees where salary > + (select max(e.salary) from jobs j left join employees e on j.job_id = e.job_id where j.job_id = 'SA_MAN'); + +#4.查询和姓名中包含字母u的员工在相同部门的员工的员工号和姓名 + #select * from employees where last_name like '' +#5.查询部门的location_id为1700的部门的工作的员工的员工号 + select employee_id 员工号 from employees where department_id in + (select department_id from departments where location_id = 1700); + +#6.查询管理者是 金 的员工姓名和工资 + select last_name 姓名,salary 工资 from employees where manager_id in + (select employee_id from employees where last_name = '金'); + +#7.查询工资最低的员工信息: last_name, salary + select last_name,salary from employees where salary = + (select min(salary) from employees); + + + +#8.查询平均工资最低的部门信息 + +#方式1: +# 部门最低工资=全司最低 +#方式2: +# 部门平均<= 公司所有平均 + select d.*,avg(e.salary) 平均工资 from departments d right join employees e on d.department_id = e.department_id group by d.department_id order by 平均工资 limit 0,1; + + +#9.查询平均工资最低的部门信息和该部门的平均工资(相关子查询) +#方式:先查最低平均工资的部门,再根据其id去select中再子查询 + + # 连表查 + select d.*,avg(e.salary) 平均工资 from departments d right join employees e on d.department_id = e.department_id group by d.department_id order by 平均工资 limit 0,1; + # 子查询 + select d.*,a.平均工资 from departments d right join + (select department_id,avg(salary) 平均工资 from employees group by department_id having avg(salary) = + (select avg(salary) 平均工资 from employees group by department_id order by 平均工资 limit 0,1)) a + on d.department_id = a.department_id; + + +#10.查询平均工资最高的 job 信息 + +#方式1:平均工资=最大 +#方式2:平均工资>=所有平均工资 + select j.*,avg(e.salary) 平均工资 + from jobs j right join employees e on j.job_id = e.job_id group by j.job_id order by 平均工资 desc limit 0,1; + +#11.查询平均工资高于公司平均工资的部门有哪些? + select d.department_name 部门名,avg(e.salary) 平均工资 + from departments d right join employees e on d.department_id = e.department_id + group by d.department_id having 平均工资 > (select avg(salary) from employees); + +#12.查询出公司中所有 manager 的详细信息 + +#方式1:自连接 自己连自己 + select * from employees where employee_id in + (select distinct(a.employee_id) from + (select e2.* from employees e1 left join employees e2 on e1.manager_id = e2.employee_id) a); + +#方式2:子查询 +#员工编号=(管理员编号有哪些) + select * from employees where employee_id in + (select distinct manager_id from employees); + +#13.各个部门中 最高工资中 最低的那个部门的 最低工资是多少? + select min(e.salary) 最低工资 from employees e right join + (select department_id,max(salary) 最高工资 from employees group by department_id order by 最高工资 limit 0,1) a + on e.department_id = a.department_id ; + +#14.查询平均工资最高的部门的 manager 的详细信息: last_name, department_id, email, salary +#方式1: + select last_name, department_id, email, salary from employees where employee_id = + (select employee_id from employees e right join + (select department_id,avg(salary) 平均工资 from employees group by department_id order by 平均工资 desc limit 0,1) a + on e.department_id = a.department_id limit 0,1); + +#15. 查询部门的部门号,其中不包括job_id是"ST_CLERK"的部门号 +#方式1: + select job_id from jobs where job_id != 'ST_CLERK'; + +#16. 选择所有没有管理者的员工的last_name + select last_name from employees where manager_id is null; + +#17.查询员工号、姓名、雇用时间、工资,其中员工的管理者为 'De Haan' +#方式1: + select * from employees where last_name = 'De Haan' + +#方式2: + +#18.查询各部门中工资比本部门平均工资高的员工的员工号, 姓名和工资(相关子查询) + +#方式1:使用相关子查询 + select e.employee_id 员工号,e.last_name 姓名,e.salary 工资,a.平均工资 from employees e left join + (select department_id,avg(salary) 平均工资 from employees group by department_id) a + on e.department_id = a.department_id and e.salary > a.平均工资; + +#方式2:在FROM中声明子查询 + +#19.查询每个部门下的部门人数大于 5 的部门名称(相关子查询) + select department_name from departments where department_id in + (select distinct department_id from employees where employee_id in + (select manager_id from employees group by manager_id having count(manager_id)>5)); + + +#20.查询每个国家下的部门个数大于 2 的国家编号(相关子查询) + select country_id from locations where location_id in + (select location_id from departments group by location_id having count(location_id) > 2); + +/* +子查询的编写技巧(或步骤):① 从里往外写 ② 从外往里写 + +如何选择? +① 如果子查询相对较简单,建议从外往里写。一旦子查询结构较复杂,则建议从里往外写 +② 如果是相关子查询的话,通常都是从外往里写。 + +*/ +``` \ No newline at end of file