
MySQL实训2
������������employee������������������������������
发布日期:2021-05-12 16:03:11
浏览次数:12
分类:精选文章
本文共 3634 字,大约阅读时间需要 12 分钟。
MySQL������������
Step 1: ���������������
������MySQL������������������������������������
mysql -u root -p
���������������yi
���
create database yi;
Step 2: ������������������
create table employee( empid varchar(10) primary key not null, name varchar(10), gender varchar(10), title varchar(20), birthday date, depid varchar(10));
������������������
desc employee;
- ������������department������������������������������
- ������������salary������������������������������
- ���������������
- ���������������
- ���������������
- ���������������
- ���������������������������������������������
- ������������������������������������
- ���������������������������������45���������������
- ������������������������������������
- ������������������������
- ������������������������������������������
create table department( depid varchar(10) primary key not null, depname varchar(20));
������������������
desc department;
create table salary( empid varchar(10) primary key not null, base_salary decimal(8,2), title_salary decimal(8,2), deduction int);
������������������
desc salary;
Step 3: ���������������
������������������������������������������������
alter table employee add column department_profile varchar(100);
������������������
desc employee;
Step 4: ������������
insert into employee values ('1001', '������', '���', '���������������', '1980-01-01', '1111', null), ('1002', '������', '���', '���������������', '1980-01-01', '1111', null), ('1003', '������', '���', '���������', '1980-01-21', '2222', null), ('1004', '������', '���', '���������', '1980-01-11', '2222', null);
���������������
select * from employee;
insert into department values ('1111', '���������'), ('2222', '���������'), ('3333', '���������');
���������������
select * from department;
insert into salary values ('1001', 3200, 1200, 200), ('1002', 4200, 1100, 100), ('1003', 5200, 2200, 200), ('1004', 2000, 1500, 150);
���������������
select * from salary;
Step 5: ������������
���������������������������������������������������������������
update employee set title = '���������' where name = '������';
select empid from employee where name = '������'; -- ������������empid���1002update salary set base_salary = 5700, title_salary = 600 where empid = '1002';
������������������������
select * from employee;select * from salary;
Step 6: ������������
select employee.empid, name, title, depname, (base_salary + title_salary - deduction) as ������������, (base_salary + title_salary) as ������������from employee left join salary on employee.empid = salary.empidleft join department on department.depid = employee.depid;
���������������
select * from employee;
select * from employee where name like '���%' and (year(curdate()) - year(birthday)) < 40;
���������������
select * from employee where name like '���%';
select employee.empid, name, title, depname, (base_salary + title_salary - deduction) as ������������from employee left join salary on employee.empid = salary.empidleft join department on department.depid = employee.depidwhere depname = '���������';
���������������
select * from department;
Step 7: ������������
select title, count(*) as ������ from employee group by title;
���������������
select * from employee;
select depname, sum(base_salary + title_salary - deduction) as ������������, avg(base_salary + title_salary - deduction) as ������������from employee left join salary on employee.empid = salary.empidleft join department on department.depid = employee.depidgroup by depname;
���������������
select * from department;
发表评论
最新留言
网站不错 人气很旺了 加油
[***.192.178.218]2025年04月05日 02时52分55秒
关于作者

喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
SQL基础语法
2021-05-10
git拉取远程指定分支代码
2021-05-10
C语言--C语言总结大纲
2021-05-10
《web安全入门》(四)前端开发基础Javascript
2021-05-10
python中列表 元组 字典 集合的区别
2021-05-10
python struct 官方文档
2021-05-10
Android DEX加固方案与原理
2021-05-10
Android Retrofit2.0 上传单张图片和多张图片
2021-05-10
iOS_Runtime3_动态添加方法
2021-05-10
Leetcode第557题---翻转字符串中的单词
2021-05-10
Problem G. The Stones Game【取石子博弈 & 思维】
2021-05-10
Unable to execute dex: Multiple dex files
2021-05-10
eclipse自动补全代码(Auto activation只能输3个字符)
2021-05-10
Java多线程
2021-05-10
Unity监听日记
2021-05-10
AndroidStudio跳到错误位置
2021-05-10
木马开发的基本理论基础(五)
2021-05-10
openssl服务器证书操作
2021-05-10