Skip to content

Commit

Permalink
更新了数据库部分的文档和代码
Browse files Browse the repository at this point in the history
  • Loading branch information
jackfrued committed Mar 28, 2021
1 parent 6a639f0 commit 7efa67b
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 226 deletions.
2 changes: 1 addition & 1 deletion Day36-40/36-38.关系型数据库MySQL.md
Original file line number Diff line number Diff line change
Expand Up @@ -1081,7 +1081,7 @@ drop procedure sp_score_by_cid;
- 检查约束(check)
> 说明:在MySQL数据库中,检查约束并不起作用。
> **说明**:在MySQL数据库中,检查约束并不起作用。
#### 数据一致性
Expand Down
43 changes: 19 additions & 24 deletions Day36-40/code/HRS_create_and_init.sql
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
drop database if exists hrs;
create database hrs default charset utf8mb4 collate utf8_bin;
create database hrs default charset utf8mb4;

use hrs;

drop table if exists tb_emp;
drop table if exists tb_dept;

create table tb_dept
(
dno int not null comment '编号',
Expand All @@ -14,13 +11,11 @@ dloc varchar(20) not null comment '所在地',
primary key (dno)
);

-- alter table tb_dept add constraint pk_dept_dno primary key(dno);

insert into tb_dept values
(10, '会计部', '北京'),
(20, '研发部', '成都'),
(30, '销售部', '重庆'),
(40, '运维部', '深圳');
(10, '会计部', '北京'),
(20, '研发部', '成都'),
(30, '销售部', '重庆'),
(40, '运维部', '深圳');

create table tb_emp
(
Expand All @@ -40,20 +35,20 @@ foreign key (mgr) references tb_emp(eno)
-- alter table tb_emp add constraint fk_emp_dno foreign key (dno) references tb_dept (dno);

insert into tb_emp values
(7800, '张三丰', '总裁', null, 9000, 1200, 20),
(2056, '乔峰', '分析师', 7800, 5000, 1500, 20),
(3088, '李莫愁', '设计师', 2056, 3500, 800, 20),
(3211, '张无忌', '程序员', 2056, 3200, null, 20),
(3233, '丘处机', '程序员', 2056, 3400, null, 20),
(3251, '张翠山', '程序员', 2056, 4000, null, 20),
(5566, '宋远桥', '会计师', 7800, 4000, 1000, 10),
(5234, '郭靖', '出纳', 5566, 2000, null, 10),
(3344, '黄蓉', '销售主管', 7800, 3000, 800, 30),
(1359, '胡一刀', '销售员', 3344, 1800, 200, 30),
(4466, '苗人凤', '销售员', 3344, 2500, null, 30),
(3244, '欧阳锋', '程序员', 3088, 3200, null, 20),
(3577, '杨过', '会计', 5566, 2200, null, 10),
(3588, '朱九真', '会计', 5566, 2500, null, 10);
(7800, '张三丰', '总裁', null, 9000, 1200, 20),
(2056, '乔峰', '分析师', 7800, 5000, 1500, 20),
(3088, '李莫愁', '设计师', 2056, 3500, 800, 20),
(3211, '张无忌', '程序员', 2056, 3200, null, 20),
(3233, '丘处机', '程序员', 2056, 3400, null, 20),
(3251, '张翠山', '程序员', 2056, 4000, null, 20),
(5566, '宋远桥', '会计师', 7800, 4000, 1000, 10),
(5234, '郭靖', '出纳', 5566, 2000, null, 10),
(3344, '黄蓉', '销售主管', 7800, 3000, 800, 30),
(1359, '胡一刀', '销售员', 3344, 1800, 200, 30),
(4466, '苗人凤', '销售员', 3344, 2500, null, 30),
(3244, '欧阳锋', '程序员', 3088, 3200, null, 20),
(3577, '杨过', '会计', 5566, 2200, null, 10),
(3588, '朱九真', '会计', 5566, 2500, null, 10);


-- 查询月薪最高的员工姓名和月薪
Expand Down
Loading

0 comments on commit 7efa67b

Please sign in to comment.