From ca112ef18a0a92b96b6c298bc7e64abe171fce28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=96=87=E9=94=8B?= <2069827762@qq.com> Date: Thu, 21 Sep 2023 22:57:18 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20230908 powerdesigner.md" | 131 +++ .../20230919MySQL\345\244\215\344\271\240.md" | 764 ++++++++++++++++++ .../20230920RBAC.md" | 158 ++++ 3 files changed, 1053 insertions(+) create mode 100644 "07 \345\210\230\346\226\207\351\224\213/20230908 powerdesigner.md" create mode 100644 "07 \345\210\230\346\226\207\351\224\213/20230919MySQL\345\244\215\344\271\240.md" create mode 100644 "07 \345\210\230\346\226\207\351\224\213/20230920RBAC.md" diff --git "a/07 \345\210\230\346\226\207\351\224\213/20230908 powerdesigner.md" "b/07 \345\210\230\346\226\207\351\224\213/20230908 powerdesigner.md" new file mode 100644 index 0000000..6735b56 --- /dev/null +++ "b/07 \345\210\230\346\226\207\351\224\213/20230908 powerdesigner.md" @@ -0,0 +1,131 @@ +## powerdesigner + +第一步:创建概念模型图(CDM)以用户角度 + +第二步:转换逻辑模型图(LDM)以计算机角度 + +第三步:转换物理模型图(PDM)以数据角度 + +第四步:生成DDL + +表与表的关系:一个表里的几条记录对应另一个表的几条记录 + +数据库范式在实际中不会完全按照范式,根据需求实际操作 + +~~~java +## 题目:图书管理系统 + +```mysql +create database lib charset utf8; + +use lib; + +/*==============================================================*/ +/* DBMS name: MySQL 5.0 */ +/* Created on: 2023/9/10 18:25:47 */ +/*==============================================================*/ + + +drop table if exists administrator; + +drop table if exists book; + +drop table if exists reader; + +drop table if exists stacks; + +drop table if exists system; + +drop table if exists type; + +/*==============================================================*/ +/* Table: administrator */ +/*==============================================================*/ +create table administrator +( + a_id char(10) not null, + a_name char(5) not null, + primary key (a_id) +); + +/*==============================================================*/ +/* Table: book */ +/*==============================================================*/ +create table book +( + b_id int not null auto_increment, + b_name varchar(10) not null, + author varchar(5) not null, + publication varchar(10) not null, + b_num int not null, + primary key (b_id) +); + +/*==============================================================*/ +/* Table: reader */ +/*==============================================================*/ +create table reader +( + r_id int not null auto_increment, + r_name char(5) not null, + r_sex char(1) not null, + r_age int not null, + primary key (r_id) +); + +/*==============================================================*/ +/* Table: stacks */ +/*==============================================================*/ +create table stacks +( + s_id int not null auto_increment, + b_id int not null, + s_name varchar(5) not null, + s_address varchar(5) not null, + primary key (s_id) +); + +/*==============================================================*/ +/* Table: system */ +/*==============================================================*/ +create table system +( + date_id int not null auto_increment, + b_id int not null, + r_id int not null, + a_id char(10) not null, + borrow date not null, + `return` date not null, + actual date, + primary key (date_id) +); + +/*==============================================================*/ +/* Table: type */ +/*==============================================================*/ +create table type +( + type_id int not null auto_increment, + b_id int not null, + type_name varchar(3) not null, + primary key (type_id) +); + +alter table stacks add constraint FK_deposit foreign key (b_id) + references book (b_id) on delete restrict on update restrict; + +alter table system add constraint FK_Relationship_3 foreign key (b_id) + references book (b_id) on delete restrict on update restrict; + +alter table system add constraint FK_Relationship_4 foreign key (r_id) + references reader (r_id) on delete restrict on update restrict; + +alter table system add constraint FK_manage foreign key (a_id) + references administrator (a_id) on delete restrict on update restrict; + +alter table type add constraint FK_categorize foreign key (b_id) + references book (b_id) on delete restrict on update restrict; + + +``` +~~~ \ No newline at end of file diff --git "a/07 \345\210\230\346\226\207\351\224\213/20230919MySQL\345\244\215\344\271\240.md" "b/07 \345\210\230\346\226\207\351\224\213/20230919MySQL\345\244\215\344\271\240.md" new file mode 100644 index 0000000..8e2e00d --- /dev/null +++ "b/07 \345\210\230\346\226\207\351\224\213/20230919MySQL\345\244\215\344\271\240.md" @@ -0,0 +1,764 @@ +## mysql复习 + +如果值是null,那么所有null参与运算,返回的结果也都是null + +所以遇上null,却又必须让它参与运算,就使用 ifnull (原值,新值) + +这个函数的作用,如果原值是null,就用新值代替,如果原值不null,就保持原值 + +limit 起始数,显示数 + +desc 库名:显示表结构 + +length(email):email的字节长度 + +#### 自然连接 + +表,表 where 字段=字段 and 字段=字段 + +#### 联表区间 + +表 left join 表 on 表.字段 between 表.字段 and 表.字段(不支持别名) + +#### 自连接 + +inner join + +not in(条件,条件) + +!(between 20 and 50) + + + +~~~java +### 建库建表 + +```mysql +create database db1 charset utf8; + +use db1; +/* + 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; +``` + +### 查询语句 + +```mysql +#第03章_基本的SELECT语句的课后练习 + +# 1.查询所有员工12个月的工资总和,并起别名为工资总和 + +#理解1:计算12月的基本工资 + +#SELECT sum(salary*12) as 工资总和 FROM employees; + +select sum(12*salary) from employees; + +#理解2:计算12月的基本工资和奖金 +# ifnull(原值,新值) 判断一个原值是否为null,如果原值是null,就用一个新值代替 + +select sum(salary*12+ifnull(salary*commission_pct*12,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 employee_id,salary,grade_level from employees e left join job_grades j on e.salary between j.lowest_sal and j.highest_sal where commission_pct is not null; + +# 5.选择员工姓名的第三个字是 尔 的员工姓名 + +select * 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 e.first_name,j.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,110 的员工姓名、工资、管理者id + +select first_name,salary,manager_id from employees where manager_id in (100,101,110); + +#第05章_排序与分页的课后练习 + +#1. 查询员工的姓名和部门号和年薪,按年薪降序显示 +-- order by 年薪 asc/desc + +select first_name,department_id,salary*12 from employees order by salary*12 desc; + +#2. 选择工资不在 8000 到 17000 的员工的姓名和工资,按工资降序,显示第21到40位置的数据 + +select first_name,salary from employees where salary not between 8000 and 17000 order by salary desc limit 20,20; + +#3. 查询邮箱中包含 e 的员工信息,并先按邮箱的字节数降序,再按部门号升序 + +select * from employees where email like '%e%' order by length(email) desc,department_id asc; + +# 第06章_多表查询的课后练习 + +# 1.显示所有员工的姓名,部门号和部门名称。 + +select first_name,e.department_id,department_name from employees e left join departments d on e.department_id=d.department_id; + +# 2.查询90号部门员工的job_id和90号部门的location_id + +select e.job_id,d.location_id from employees e left join departments d on e.department_id=d.department_id where e.department_id=90; + +# 3.选择所有 有奖金的员工 的 last_name , department_name , location_id , city + +select e.last_name,d.department_name,d.location_id,l.city from employees e left join departments d on e.department_id=d.department_id left join locations l on d.location_id=l.location_id where commission_pct is not null; + +# 4.选择city在 多伦多 工作的员工的 last_name , job_id , department_id , department_name + +select e.last_name,e.job_id,d.department_id,d.department_name from employees e left join departments d on e.department_id=d.department_id left join locations l on d.location_id=l.location_id where l.city='多伦多'; + +#sql92语法(自然连接): + +# 5.查询行政部门员工的部门名称、部门地址、姓名、工作、工资 + +select department_name,street_address,first_name,job_title,salary from jobs j,employees e,departments d,locations l where j.job_id=e.job_id and e.department_id=d.department_id and d.location_id=l.location_id and department_name='行政部'; + +# 6.显示所有员工的姓名,员工号,以及他的管理者的姓名和员工号,结果类似于下面的格式 +-- 员工姓名 员工编号 上级姓名 上级的员工编号 +-- 德哈恩 102 金 100 + +select e.first_name,e.employee_id,s.last_name,s.employee_id from employees e inner join employees s on e.employee_id=s.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 departments d right join locations l on d.location_id=l.location_id where department_id is null; + +# 9. 查询部门名为 销售部 或 信息技术部 的员工信息 + +select e.* from departments d,employees e where d.department_id=e.department_id and d.department_name='销售部' or d.department_name='信息技术部'; + +# 第08章_聚合函数的课后练习 + +#2.查询公司员工工资的最大值,最小值,平均值,总和 + +select max(salary),min(salary),avg(salary),sum(salary) from employees; + +#3.查询各job_id的员工工资的最大值,最小值,平均值,总和 + +select job_id,max(salary),min(salary),avg(salary),sum(salary) from employees group by job_id; + +#4.选择各个job_id的员工人数 + +select job_id,count(employee_id) from employees group by job_id; + +# 5.查询员工最高工资和最低工资的差距 + +select max(salary)-min(salary) from employees; + +# 6.查询各个管理者 手下员工的最低工资,其中最低工资不能低于6000,没有管理者的员工不计算在内 + +select manager_id,min(salary) from employees where manager_id is not null group by manager_id having min(salary)>6000; + +# 7.查询所有部门的名字,location_id,员工数量和平均工资,并按平均工资降序 + +select d.department_name,d.location_id,count(employee_id),avg(salary) from departments d left join employees e on d.department_id=e.department_id group by d.department_id order by avg(salary) desc; + +# 8.查询每个工种、每个部门的部门名、工种名和最低工资 + +select j.job_title,min(salary),department_name from jobs j left 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 * from employees where department_id =(select department_id from employees where last_name='兹洛特基') and salary=(select salary from employees where last_name='兹洛特基'); + +#2.查询工资比公司平均工资高的员工的员工号,姓名和工资。 + +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(salary) from employees where JOB_ID = 'SA_MAN'); + +#4.查询和姓名中包含字母u的员工在相同部门的员工的员工号和姓名 + +select employee_id,last_name from employees where department_id=(select department_id from employees where last_name like '%u%'); + +#5.查询部门的location_id为1700的部门的工作的员工的员工号 + +select first_name,employee_id from employees where department_id in (select department_id from departments where location_id=1700); + +#6.查询管理者是 金 的员工姓名和工资 + +select first_name,salary from employees where manager_id in (select manager_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: +# 部门最低工资=全司最低 + +select * from departments where department_id =(select department_id from employees group by department_id having avg(salary)=(select min(s) from (select avg(salary) s from employees group by department_id) a)); + +#方式2: +# 部门平均<= 公司所有平均 + +select * from departments where department_id=(select department_id from employees group by department_id having avg(salary)<=all(select avg(salary) from employees group by department_id)); + +#9.查询平均工资最低的部门信息和该部门的平均工资(相关子查询) +#方式:先查最低平均工资的部门,再根据其id去select中再子查询 + +select d.*,(select avg(salary) from employees where department_id=d.department_id) from departments d where department_id =(select department_id from employees group by department_id having avg(salary)=(select min(s) from (select avg(salary) s from employees group by department_id) a)); + +#10.查询平均工资最高的 job 信息 + +#方式1:平均工资=最大 + +select * from jobs where job_id=(select job_id from employees group by job_id having avg(salary)=(select max(s) from (select avg(salary) s from employees group by job_id) a)); + +#方式2:平均工资>=所有平均工资 + +select * from jobs where job_id=(select job_id from employees group by job_id having avg(salary)>=all(select avg(salary) from employees group by job_id)); + +#11.查询平均工资高于公司平均工资的部门有哪些? + +select department_id from employees where department_id is not null group by department_id having avg(salary)>(select avg(salary) from employees); + +#12.查询出公司中所有 manager 的详细信息 + +#方式1:自连接 自己连自己 + +select e.* from employees e inner join employees s on e.employee_id=s.manager_id; + +#方式2:子查询 +#员工编号=(管理员编号有哪些) + +select * from employees where employee_id=any(select distinct manager_id from employees); + +#13.各个部门中 最高工资中 最低的那个部门的 最低工资是多少? + +select min(salary) from employees group by department_id having max(salary)<=all(select max(salary) from employees group by department_id); + +#14.查询平均工资最高的部门的 manager 的详细信息: last_name, department_id, email, salary + +select last_name,department_id,email,salary from employees where department_id = (select department_id from employees group by department_id having avg(salary)>=all(select avg(salary) from employees group by department_id)); + +#15. 查询部门的部门号,其中不包括job_id是"ST_CLERK"的部门号 + +select department_id from departments where department_id !=all(select department_id from employees where job_id='ST_CLERK'); + +#16. 选择所有没有管理者的员工的last_name + +select last_name from employees where manager_id is null; + +#17.查询员工号、姓名、雇用时间、工资,其中员工的管理者为 'De Haan' +#方式1: + +select employee_id,first_name,hire_date,salary from employees e where e.manager_id=(select employee_id from employees where first_name = 'De Haan'); + +#方式2: + +select employee_id, last_name, hire_date, salary from employees e where exists(select * from employees s where e.employee_id=s.manager_id and s.first_name='De Haan'); + +#18.查询各部门中工资比本部门平均工资高的员工的员工号, 姓名和工资(相关子查询) + +#方式1:使用相关子查询 + +select employee_id,last_name,salary from employees e1 where salary > (select avg(salary) from employees e2 where e2.department_id = e1.department_id); + +#方式2:在FROM中声明子查询 + +select employee_id,last_name,salary from employees e1,(select department_id,AVG(salary) s from employees e2 group by department_id) a where e1.department_id = a.department_id and e1.salary > a.s; + +#19.查询每个部门下的部门人数大于 5 的部门名称(相关子查询) + +select department_name,department_id from departments d where 5 < (select count(*) from employees e where d.department_id = e.department_id); + +#20.查询每个国家下的部门个数大于 2 的国家编号(相关子查询) + +select country_id from locations l where 2 < (select count(*) from departments d where l.location_id=d.location_id); + +/* +子查询的编写技巧(或步骤):① 从里往外写 ② 从外往里写 + +如何选择? +① 如果子查询相对较简单,建议从外往里写。一旦子查询结构较复杂,则建议从里往外写 +② 如果是相关子查询的话,通常都是从外往里写。 +~~~ \ No newline at end of file diff --git "a/07 \345\210\230\346\226\207\351\224\213/20230920RBAC.md" "b/07 \345\210\230\346\226\207\351\224\213/20230920RBAC.md" new file mode 100644 index 0000000..f0f946f --- /dev/null +++ "b/07 \345\210\230\346\226\207\351\224\213/20230920RBAC.md" @@ -0,0 +1,158 @@ +## RBAC(Role-Based Access Control) + +一种数据库设计思想,基于角色的访问权限管制模型,目前权限的主流方案,核心为角色 + +在 RBAC 模型里面,有3个基础组成部分,分别是:用户、角色和权限 + +- User(用户):每个用户都有唯一的UID识别,并被授予不同的角色 +- Role(角色):不同角色具有不同的权限 +- Permission(权限):访问权限 +- 用户-角色映射:用户和角色之间的映射关系 +- 角色-权限映射:角色和权限之间的映射 + +管理员和普通用户被授予不同的权限,普通用户只能去修改和查看个人信息,而不能创建用户和冻结用户,而管理员由于被授予所有权限,所以可以做所有操作 + +## 预习 SKU + +SKU 英文全称为Stock Keeping Unit,简称 SKU ,是产品入库后一种编码归类方法,也是库存控制的最小单位。一款商品,每个颜色,每个尺码,每一型号等都有出现一个 sku ,便于电商品牌识别商品。 + +既然 sku 被定义为最小存货单元,商家就可以选择自己设定 sku,一般来说是以件、盒、个、托盘等为单位。 + +- 大厂的 sku 就可以是一箱, +- 超市的 sku 就可以是一盒, +- 零售商的 sku 可以是一个。 + +~~~java +## RBAC练习 + +```mysql +/*==============================================================*/ +/* DBMS name: MySQL 5.0 */ +/* Created on: 2023-09-20 15:30:32 */ +/*==============================================================*/ +create database school charset utf8; + +use school; + +drop table if exists management; + +drop table if exists role; + +drop table if exists role_management; + +drop table if exists user; + +drop table if exists user_role; + +/*==============================================================*/ +/* Table: management */ +/*==============================================================*/ +create table management +( + management_id int not null auto_increment, + management_name varchar(10) not null, + managemen_comment varchar(50) not null, + management_type char(10) not null, + primary key (management_id) +); + +/*==============================================================*/ +/* Table: role */ +/*==============================================================*/ +create table role +( + role_id int not null auto_increment, + role_name varchar(3) not null, + role_comment char(10) not null, + primary key (role_id) +); + +/*==============================================================*/ +/* Table: role_management */ +/*==============================================================*/ +create table role_management +( + management_id int not null, + role_id int not null, + primary key (management_id, role_id) +); + +/*==============================================================*/ +/* Table: user */ +/*==============================================================*/ +create table user +( + user_id int not null auto_increment, + user_name varchar(5) not null, + user_pwd char(6) not null, + primary key (user_id) +); + +/*==============================================================*/ +/* Table: user_role */ +/*==============================================================*/ +create table user_role +( + role_id int not null, + user_id int not null, + primary key (role_id, user_id) +); + +alter table role_management add constraint FK_role_management foreign key (management_id) + references management (management_id) on delete restrict on update restrict; + +alter table role_management add constraint FK_role_management2 foreign key (role_id) + references role (role_id) on delete restrict on update restrict; + +alter table user_role add constraint FK_user_role foreign key (role_id) + references role (role_id) on delete restrict on update restrict; + +alter table user_role add constraint FK_user_role2 foreign key (user_id) + references user (user_id) on delete restrict on update restrict; + + + +-- ---------------------------- +-- Records of management +-- ---------------------------- +INSERT INTO `management` VALUES (1, '学生信息'); +INSERT INTO `management` VALUES (2, '教师信息'); +INSERT INTO `management` VALUES (3, '工资信息'); +INSERT INTO `management` VALUES (4, '首页'); + +-- ---------------------------- +-- Records of role +-- ---------------------------- +INSERT INTO `role` VALUES (1, '校长'); +INSERT INTO `role` VALUES (2, '教师'); +INSERT INTO `role` VALUES (3, '学生'); + +-- ---------------------------- +-- Records of role_management +-- ---------------------------- +INSERT INTO `role_management` VALUES (1, 1); +INSERT INTO `role_management` VALUES (2, 1); +INSERT INTO `role_management` VALUES (3, 1); +INSERT INTO `role_management` VALUES (4, 1); +INSERT INTO `role_management` VALUES (1, 2); +INSERT INTO `role_management` VALUES (2, 2); +INSERT INTO `role_management` VALUES (4, 2); +INSERT INTO `role_management` VALUES (1, 3); +INSERT INTO `role_management` VALUES (4, 3); +-- ---------------------------- +-- Records of user +-- ---------------------------- +INSERT INTO `user` VALUES (1, '一一', '123456'); +INSERT INTO `user` VALUES (2, '二二', '123456'); +INSERT INTO `user` VALUES (3, '三三', '123456'); +INSERT INTO `user` VALUES (4, '四四', '123456'); + +-- ---------------------------- +-- Records of user_role +-- ---------------------------- +INSERT INTO `user_role` VALUES (1, 1); +INSERT INTO `user_role` VALUES (2, 2); +INSERT INTO `user_role` VALUES (2, 3); +INSERT INTO `user_role` VALUES (3, 4); +``` +~~~ \ No newline at end of file -- Gitee From c1d79d45786420577a7b328d3d25a027b303ebe2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=96=87=E9=94=8B?= <2069827762@qq.com> Date: Thu, 21 Sep 2023 23:04:06 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...45\351\201\245\351\242\206\345\205\210.md" | 98 +++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 "07 \345\210\230\346\226\207\351\224\213/20230921 \351\201\245\351\201\245\351\242\206\345\205\210.md" diff --git "a/07 \345\210\230\346\226\207\351\224\213/20230921 \351\201\245\351\201\245\351\242\206\345\205\210.md" "b/07 \345\210\230\346\226\207\351\224\213/20230921 \351\201\245\351\201\245\351\242\206\345\205\210.md" new file mode 100644 index 0000000..7c7fd5b --- /dev/null +++ "b/07 \345\210\230\346\226\207\351\224\213/20230921 \351\201\245\351\201\245\351\242\206\345\205\210.md" @@ -0,0 +1,98 @@ +### 笔记 + +今天学到了sku,spu + +sku是库存量单位一个项目可能有多个SKU + +spu: 是商品信息聚合的最小单位,是一组可复用、易检索的标准化信息的集合,该集合描述了一个产品的特性。通俗点讲,属性值、特性相同的商品就可以称为一个spu + + + +~~~java + +/*==============================================================*/ +/* DBMS name: MySQL 5.0 */ +/* Created on: 2023-09-21 16:41:07 */ +/*==============================================================*/ +create database zy charset utf8; +use zy; + +drop table if exists attributes; + +drop table if exists attributes_value; + +drop table if exists relation; + +drop table if exists sku; + +drop table if exists spu; + +/*==============================================================*/ +/* Table: attributes */ +/*==============================================================*/ +create table attributes +( + attributes_id int not null auto_increment, + attributes_name varchar(50) not null, + primary key (attributes_id) +); + +/*==============================================================*/ +/* Table: attributes_value */ +/*==============================================================*/ +create table attributes_value +( + value_id int not null auto_increment, + value_content varchar(50) not null, + primary key (value_id) +); + +/*==============================================================*/ +/* Table: relation */ +/*==============================================================*/ +create table relation +( + relation_id int not null auto_increment, + sku_id int, + attributes_id int, + value_id int, + primary key (relation_id) +); + +/*==============================================================*/ +/* Table: sku */ +/*==============================================================*/ +create table sku +( + sku_id int not null auto_increment, + spu_id int, + sku_name varchar(50) not null, + sku_price decimal(9,2) not null, + sku_kc int not null, + primary key (sku_id) +); + +/*==============================================================*/ +/* Table: spu */ +/*==============================================================*/ +create table spu +( + spu_id int not null auto_increment, + spu_name varchar(50) not null, + spu_content varchar(50) not null, + primary key (spu_id) +); + +alter table relation add constraint FK_Relationship_2 foreign key (sku_id) + references sku (sku_id) on delete restrict on update restrict; + +alter table relation add constraint FK_Relationship_3 foreign key (attributes_id) + references attributes (attributes_id) on delete restrict on update restrict; + +alter table relation add constraint FK_Relationship_4 foreign key (value_id) + references attributes_value (value_id) on delete restrict on update restrict; + +alter table sku add constraint FK_Relationship_1 foreign key (spu_id) + references spu (spu_id) on delete restrict on update restrict; +``` +~~~ \ No newline at end of file -- Gitee