学号姓名Oracle练习题

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

Oracle练习题

1.向LOCATION表中插入以下2条数据

1)区域编号1(自动生成),大连

Insert into location values(seq_location.nextval,’大连’);

2)区域编号2(自动生成),

Insert into location values(seq_location.nextval);

2.查询LOCATION表中的所有区域编号

Select location_id from location;

3.向DEPARTMENT表中插入以下2条数据

1)部门编号1(自动生成),教学部,查询区域所在地是大连的该区域编号

Insert into department values(seq_department.nextval,’教学部’,(select location_id from location where city =‘大连’));

2)部门编号2(自动生成),市场部,区域编号2

Insert into department values(seq_department.nextval,’市场部’,2);

4.查询DEPARTMENT表中的所有部门编号

Select department_name form department;

5.向EMPLOYEES表中插入以下2条数据

1)雇员编号1(自动生成),张三,部门编号1,teacher1,3000,2006-9-5,aa@ Insert into employees values(seq_employees.nextval,

‘张三’,1,’teacher1’,3000,to_date(’2006-9-5’,’yyyy-mm-dd’),’aa@’);

2)雇员编号2(自动生成),李四,部门编号2,agora1,2500,2006-9-5,,82365421 Insert into employees values(seq_employees.nextval,’李四’,2,’agoral’,2500,to_date(‘2006-9-5’,’yyyy-mm-dd’),82365421);

6.查询EMPLOYEES表中所有的数据

Select * from employees;

7.查询EMPLOYEES表中薪水大于2500的所有数据

select * from employees where salary > 2500;

8.查询EMPLOYEES表中薪水大于等于2500的所有数据

Select * from employees where salary>=2500;

9.查询EMPLOYEES表中薪水小于2500的所有数据

Select * from employees where salary < 2500;

10.查询EMPLOYEES表中薪水小于等于2500的所有数据

Select * from employees where salary < =2500;

11.查询EMPLOYEES表中薪水不等于2500的所有数据(要求2种写法)

Select * from employees where salary != 2500;

Select * from employees where salary <> 2500;

12.查询EMPLOYEES表中雇员编号在1~10之间的所有数据,包括1和10

Select * from employees where employees_id between 1 and 10;

13.查询EMPLOYEES表中雇员编号不是2的所有雇员信息

Select * from employees where employees_id <>2;

14.查询EMPLOYEES表中雇员姓名中第二个字是“三”的雇员的所有信息

Select * from employees where last_name like ‘_三%’;

15.查询EMPLOYEES表中电话为空的雇员的所有信息

Select * from employees where phone_number is null;

16.查询EMPLOYEES表中现有数据的个数

Select count(*) from employees;

17.查询EMPLOYEES表中最大薪水值

Select max(salary) from employees;

18.查询EMPLOYEES表中最小薪水值

Select min(salary) from employees;

19.查询EMPLOYEES表中薪水的平均值

Select avg(salary) from employees;

20.查询EMPLOYEES表中所有薪水的和

Select sum(salary) from employees;

21.查询EMPLOYEES表中部门的编号和该部门的平均薪水(使用分组查询)

Select department_id,avg(salary) from employees group by department_id;

22.查询EMPLOYEES表中的所有信息,要求根据雇员姓名倒序排列

Select * from employees order by last_name desc;

23.把雇员姓名为“张三”的工资涨到3500,把工资为2500的雇员的工资涨到3000

Update employees set salary=3500 where last_name like ‘张三’;

Update employees set salary=3000 where salary=2500;

24.根据区域编号2查询LOCATION表中该区域所在的城市,如果结果为空值则用“大连”

来代替

Select nvl(city,’大连’) from location where location_id=2;

25.根据雇员姓名为“张三”的查询EMPLOYEES表中该雇员的工作编号,并以此作为条

件查询EMPLOYEES表中该雇员的姓名、工作编号、薪水等信息(使用子查询)

Select last_name,job_id,salary from employees where job_id=(select job_id from employees where last_name like ‘张三’);

26.查询EMPLOYEES表中的最少薪水,并根据这个结果查询EMPLOYEES表中薪水等于

这个值的雇员编号、姓名、工作编号和薪水等信息(使用子查询)

Select employees_id,employees_name,job_id,salary from employees where salary=(select min(salary) from employees);

相关文档
最新文档