oracle笔试题oracle笔试题.pdf
文本预览下载声明
CORE-E-001
( )综合练习
定义
CORE-F-001——CORE-F-005 的综合练习:
1. 用sqlplus连接数据库时,为什么会出Oracle notavailable错误?
Oracleserver(即通常所说的数据库)是否启动,ORACLE_SID是否正确设置。
2. 找出员工的姓中(last_name)第三个字母是a 的员工名字
select last_namefrom s_empwhere last_namelike__a%;
3. 找出员工名字中含有a和e 的
selectfirst_namefroms_empwherefirst_name like%a%andfirst_name like
%e%;
比较:
selectfirst_namefroms_empwherefirst_name like%a%e%;
此种方式查询出来的数据,只是先出现“a”然后出现 “e”的数据表记录。总的
记录条数可能少于第一种方式的。
4. 找出所有有提成的员工,列出名字、工资、提出,显示结果按工资从小到大,
提成从小到大.
selectfirst_name,salary,commission_pct from s_empwhere commission_pct is
notnullorder bysalarydesc,commission_pct;
5. 42部门有哪些职位
selectdistincttitlefroms_empwheredept_id=42;
6. 哪些部门不是Sales部
select id,name,region_idfrom s_deptwhere name Sales;
注意大小写!
7. 显示工资不在1000到1550之间的员工信息:名字、工资,按工资从大到小
排序。
selectfirst_name,salaryfrom s_empwheresalary notbetween 1000and 1550
order bysalarydesc;
需要使用到notbetweenand 函数,不能使用 salary 1550andsalary 1000
8. 显示职位为StockClerk和SalesRepresentative,年薪在14400和17400之
间的员工的信息:名字、职位、年薪。
select first_name,title,salary*12 ann_sal from s_emp where title in (Stock
Clerk,Sales Representative)andsalary between 1200and 1450;
注意把年薪的范围换算成了每月的工资salary,而不是salary*12。以提高查
询效率。
9. 解释select id,commission_pctfroms_empwherecommission_pct isnull和
select id,commission_pctfrom s_empwhere commission_pct =null的输出
结果。
isnull判断是否为空,=null判断某个值是否等于null,null=null和nullnull
都为null。
第一条语句有输出结果,就是没有提成的ID号。
第二条语句没有输出。
10.select语句的输出结果为
select*from s_dept;
select*from s_emp;
select*from s_region;
select*from s_customer;
……
当前用户有多少张表,结果集有多少条记录。
selectselect*from ||table_name||;from user_tables;
11.判断selectfirst_name,dept_idfroms_empwheresalary 1450是否抱错,
为什么?
隐式数据类型转换
CORE-E-002
( )综合练习
定义
CORE-F-006——CORE-F-008 的综合练习:
1. 改变NLS_LANG的值,让selectto_char(salary*12,’L99,999.99’)froms_emp
输出结果的货币单位是¥和$
setenv NLS_LANGSIMPLIFIEDCHINESE_CHINA.ZHS16GBK
显示全部