Oracle数据库面试练习题

时间:2018-12-31 12:00:00 资料大全 我要投稿

Oracle数据库面试练习题

  1.列出至少有一个员工的所有部门,

Oracle数据库面试练习题

Oracle数据库面试练习题

  分析:每个部门有多少员工 —— 根据部门编号进行分组

  select deptno,count(*) from emp group by deptno having count(*) >= 1;

  2.列出薪金比“SMITH”多的所有员工。

  分析:先查询出SMITH工资 : select sal from emp where ename=’SMITH’;

  select * from emp where sal > (select sal from emp where ename=’SMITH’);

  3.***** 列出所有员工的姓名及其直接上级的姓名。

  分析:表自映射,为表起别名,进行关联 t1 表模拟员工表 t2 表保存直接上级信息

  select t1.ename 员工姓名, t2.ename 直接上级 from emp t1,emp t2 where t1.MGR = t2.empno;

  4.列出受雇日期早于其直接上级的所有员工。

  分析:原理和上题类似

  select t1.*,t2.hiredate from emp t1,emp t2 where t1.MGR = t2.empno and t1.hiredate < t2.hiredate;

  5.列出部门名称和这些部门的员工信息,同时列出那些没有员工的部门。

  分析:部门没员工也要显示 — 外连接。无论怎样部门信息一定要显示,通过部门去关联员工

  select * from dept left outer join emp on dept.deptno = emp.deptno ;

  6.列出所有“CLERK”(办事员)的姓名及其部门名称。

  分析:查找job为CLERK 员工姓名和部门名称

  员工姓名 emp表

  部门名称 dept表

  select emp.ename,dept.dname,emp.job from emp,dept where emp.deptno = dept.deptno and emp.job=’CLERK’;

  7.列出最低薪金大于1500的各种工作。

  分析:工作的'最低薪金 —- 按工作分组,求最低薪金

  select min(sal) from emp group by job;

  大于1500 是一个分组条件 — having

  select job,min(sal) from emp group by job having min(sal) > 1500;

  8.列出在部门“SALES”(销售部)工作的员工的姓名,假定不知道销售部的部门编号,

资料共享平台

Oracle数据库面试练习题》(https://www.unjs.com)。

  分析:员工姓名位于 emp 部门名称 dept

  select emp.ename from emp,dept where emp.deptno = dept.deptno and dept.dname = ‘SALES’;

  9.列出薪金高于公司平均薪金的所有员工。

  分析:先求公司平均薪金 select avg(sal) from emp;

  select * from emp where sal > (select avg(sal) from emp);

  10.列出与“SCOTT”从事相同工作的所有员工。

  分析:先查询SCOTT : select job from emp where ename =’SCOTT’;

  select * from emp where ename <> ‘SCOTT’ and job = (select job from emp where ename =’SCOTT’);

  11.列出薪金等于部门30中员工的薪金的所有员工的姓名和薪金。

  分析:查看部门30 中所有员工薪资列表 select sal from emp where deptno = 30;

  select * from emp where sal in (select sal from emp where deptno = 30);

  12.列出薪金高于在部门30工作的所有员工的薪金的员工姓名和薪金。

  分析:

  select * from emp where sal > all(select sal from emp where deptno = 30);

  select * from emp where sal > (select max(sal) from emp where deptno = 30);

  13.列出在每个部门工作的员工数量、平均工资。

  分析:按部门分组

  select deptno, count(*),avg(sal) from emp group by deptno;

  14.列出所有员工的姓名、部门名称和工资。

  分析:

【Oracle数据库面试练习题】相关文章:

1.数据库oracle笔试

2.ORACLE数据库的部分试题

3.Oracle面试问题

4.Oracle的sql语句练习题

5.Oracle技术面试问题

6.甲骨文(Oracle)面试题目

7.oracle 笔试

8.Oracle笔试经验