Sql |
1. 向LOCATION表中插入以下2条数据 1) 区域编号1(自动生成),大连 2) 区域编号2(自动生成), 2. 查询LOCATION表中的所有区域编号 3. 向DEPARTMENT表中插入以下2条数据 1) 部门编号1(自动生成),教学部,查询区域所在地是大连的该区域编号 2) 部门编号2(自动生成),市场部,区域编号2 4. 查询DEPARTMENT表中的所有部门编号 5. 向EMPLOYEES表中插入以下2条数据 1) 雇员编号1(自动生成),张三,部门编号1,teacher1,3000,2006-9-5,aa@163 2) 雇员编号2(自动生成),李四,部门编号2,agora1,2500,2006-9-5,,82365421 6. 查询EMPLOYEES表中所有的数据 7. 查询EMPLOYEES表中薪水大于2500的所有数据 8. 查询EMPLOYEES表中薪水大于等于2500的所有数据 9. 查询EMPLOYEES表中薪水小于2500的所有数据 10. 查询EMPLOYEES表中薪水小于等于2500的所有数据 11. 查询EMPLOYEES表中薪水不等于2500的所有数据(要求2种写法) 12. 查询EMPLOYEES表中雇员编号在1~10之间的所有数据,包括1和10 13. 查询EMPLOYEES表中雇员编号不是2的所有雇员信息 14. 查询EMPLOYEES表中雇员姓名中第二个字是“三”的雇员的所有信息 15. 查询EMPLOYEES表中电话为空的雇员的所有信息 16. 查询EMPLOYEES表中现有数据的个数 17. 查询EMPLOYEES表中最大薪水值 18. 查询EMPLOYEES表中最小薪水值 19. 查询EMPLOYEES表中薪水的平均值 20. 查询EMPLOYEES表中所有薪水的和 常用的sql查询语句有哪些21. 查询EMPLOYEES表中部门的编号和该部门的平均薪水(使用分组查询) 22. 查询EMPLOYEES表中的所有信息,要求根据雇员姓名倒序排列 23. 把雇员姓名为“张三”的工资涨到3500,把工资为2500的雇员的工资涨到3000 24. 根据区域编号2查询LOCATION表中该区域所在的城市,如果结果为空值则用“大连”来代替 25. 根据雇员姓名为“张三”的查询EMPLOYEES表中该雇员的工作编号,并以此作为条件查询EMPLOYEES表中该雇员的姓名、工作编号、薪水等信息(使用子查询) 26. 查询EMPLOYEES表中的最少薪水,并根据这个结果查询EMPLOYEES表中薪水等于这个值的雇员编号、姓名、工作编号和薪水等信息(使用子查询) 27. 查询EMPLOYEES表中的雇员编号、姓名、部门编号和DEPARTMENT表中的部门编号、部门名称、部门所在的区域编号(使用2表连接) 28. 查询EMPLOYEES表中的雇员编号、姓名、部门编号和DEPARTMENT表中的部门编号、部门名称、部门所在的区域编号以及LOCATION表中的区域编号、该区域所在的城市(使用多表连接) 29. 查询EMPLOYEES表中的雇员姓名、部门编号和DEPARTMENT表中的部门名称(使用左连接) 30. 查询EMPLOYEES表中的雇员姓名、部门编号和DEPARTMENT表中的部门名称(使用右连接) |
答案
1.
1) insert into location (location_id, city) values (val, ‘大连')
2) insert into location (location_id) values (val)
2. select location_id from location
3.
1) insert into department (department_id, department_name, location_id) values (val, ‘教学部', (select location_id from location where city like ‘大连'))
2) insert into departion (department_id, department_name, location_id) values (val, ‘市场部', 2)
4. select departmen_id from department
5.
1) insert into employees (employees_id, last_name, department_id, job_id, salary, hire_date, email) values (val, ‘张三', 1, ‘teacher1’, 3000, to_date(‘2006-9-5’, 'yyyy-mm-dd’), 'aa@163’)
2) insert into employees (employees_id, last_name, department_id, job_id, salary, hire_date, phone_number)
values (val,‘张三',2, ‘agora1’, 2500, to_date(‘2006-9-5’, 'yyyy-mm-dd’), 82365421)
6. select * from employees
7. select * from employees where salary > 2500
8. select * from employees where salary >= 2500
9. select * from employees where salary < 2500
10. select * from employees where salary <= 2500
11. select * from employees where salary <> 2500 或 select * from employees where salary != 2500
12. select * from employees where employees_id between 1 and 10
13. select * from employees where employees_id not in (2)
14. select * from employees where last_name like ‘_三'
15. select * from employees where phone_number is null
16. select count (*) from employees
17. select max (salary) from employees
18. select min (salary) from employees
19. select avg (salary) from employees
20. select sum (salary) from employees
21. select department_id, avg (salary) from employees group by department_id
22. select * from employees order by last_name
23. update employees set salary=3500 where last_name like ‘张三'
update employees set salary=3000 where salary=2500
24. select nvl(city, ‘大连') from location where location_id=2
25. select last_name, job_id, salary from employees where job_id=
(select job_id from employees where last_name like ‘张三')
26. select employees_id, last_name, job_id, salary from employees where salary=(select min (salary) from employees)
27. ployees_id, e.last_name, e.department_id, d.department_id, d.department
_name, d.location_id from employees e, department d where e.department_id=d.department_id
28. ployees_id, e.last_name, e.department_id, d.department_id, d.department_name, d.location_id, l.location_id, l.city from employees e, department d, location l where e.department_id=d.department_id and d.location_id=l.location_id
29. select e.last_name, e.department_id, d.department_name from employees e left join department d on e.department_id=d.department_id
或者
select e.last_name, e.department_id, d.department_name from employees e, department d where e.department_id=d.department_id (+)
30. select e.last_name, e.department_id, d.department_name from employees e right join department d on e.department_id=d.department_id
或者
select e.last_name, e.department_id, d.department_name from employees e, department d where e.department_id (+)=d.department_id
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论