image

编辑人: 桃花下浅酌

calendar2025-04-20

message3

visits854

Oracle管理员及SQL面试题

  1. 用sqlplus连接数据库时,为什么会出Oracle not available错误?

Oracle server(即通常所说的数据库)是否启动,ORACLE_SID是否正确设置。

 

  1. 找出员工的姓中(last_name)第三个字母是a的员工名字

select last_name from s_emp where last_name like ‘_ _a%’;

 

  1. 找出员工名字中含有a和e的

select first_name from s_emp where first_name like ‘%a%’ and first_name like ‘%e%’;

比较:

select first_name from s_emp where first_name like ‘%a%e%’;

此种方式查询出来的数据,只是先出现“a”然后出现“e”的数据表记录。总的记录条数可能少于第一种方式的。

 

  1. 找出所有有提成的员工,列出名字、工资、提出,显示结果按工资从小到大,提成从小到大.

select first_name,salary,commission_pct from s_emp where commission_pct is not null order by salary desc,commission_pct;

 

  1. 42部门有哪些职位

select distinct title from s_emp where dept_id=42;

 

  1. 哪些部门不是Sales部

select id,name,region_id from s_dept where name <> ‘Sales’;

注意大小写!

 

  1. 显示工资不在1000到1550之间的员工信息:名字、工资,按工资从大到小排序。

select first_name,salary from s_emp where salary not between 1000 and 1550 order by salary desc;

需要使用到not between and 函数,不能使用 salary > 1550 and salary <1000

 

  1. 显示职位为Stock Clerk和Sales Representative,年薪在14400和17400之间的员工的信息:名字、职位、年薪。

select first_name,title,salary*12 ann_sal from s_emp where title in (‘Stock Clerk’,’Sales Representative’) and salary between 1200 and 1450;

注意把年薪的范围换算成了每月的工资salary,而不是salary*12。以提高查询效率。

 

  1. 解释select id,commission_pct from s_emp where commission_pct is null和select id,commission_pct from s_emp where commission_pct = null的输出结果。

is null判断是否为空,= null判断某个值是否等于null,null=null和null<>null都为null。

第一条语句有输出结果,就是没有提成的ID号。

第二条语句没有输出。

 

10.select语句的输出结果为

select * from s_dept;

select * from s_emp;

select * from s_region;

select * from s_customer;

……

当前用户有多少张表,结果集有多少条记录。

select ‘select * from ‘||table_name||’;’ from user_tables;

 

11.判断select first_name,dept_id from s_emp where salary > ‘1450’是否抱错,为什么?

隐式数据类型转换

喵呜刷题:让学习像火箭一样快速,快来微信扫码,体验免费刷题服务,开启你的学习加速器!

创作类型:
原创

本文链接:Oracle管理员及SQL面试题

版权声明:本站点所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明文章出处。
分享文章
share