- 1、本文档共6页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
一道 Oracle 笔试题附网友答案
考试总分为 100 分,共 8 题,时间为 1 小时。表结构说明:
create table employee(
id number(10) not null, — 员工工号
salary number(10,2) default 0 not null, — 薪水
name varchar2(24) not null — 姓名
);
创建序列 seq_employee,该序列每次取的时候它会自动增加,从 1 开始计数,不设最大值, 并且一直累加,不循环。(10 分)
SQL Create sequence seq_employee increment by 1 start with 1 nomaxvalue nocycle;
序列已创建。
写一个 PL/SQL 块,插入表 user.employee 中 100 条数据。插入该表中字段 id 用序列
seq_employee 实现,薪水和姓名字段可以任意填写。(15 分) SQL declare i number;
begin
for i in 1 .. 100
loop
insert into employee
values(seq_employee.nextval,1950+i,’王明’||to_char(i))
commit;
end loop;
end;
10 /
PL/SQL 过程已成功完成。
SQL select * from employee where rownum11; ID SALARY NAME
———- ———- ————————
1 1951
王明 1
2 1952
王明 2
3 1953
王明 3
4 1954
王明 4
5 1955
王明 5
6 1956
王明 6
7 1957
王明 7
8 1958 王明 8
9 1959 王明 9
10 1960 王明 10
已选择 10 行。
写一个语句块,在语句块中定义一个显式游标,按 id 升序排列,打印表 employee 中前十条数据。(15 分)
——-第三题答案:
SQL declare
2 cursor c is select id,salary,name from(select * from employee order by id) where rownum11; 3 v_record c%rowtype;
begin
open c;
loop
fetch c into v_record;
exit when c%notfound;
dbms_output.put_line(to_char(v_record.id)||’,||to_char(v_record.salary)||’,||v_record.name);
end loop;
close c;
end;
13 /
1,1951,王明 1
2,1952,王明 2
3,1953,王明 3
4,1954,王明 4
5,1955,王明 5
6,1956,王明 6
7,1957,王明 7
8,1958,王明 8
9,1959,王明 9
10,1960,王明 10
PL/SQL 过程已成功完成。
创建存储过程 p_employee,输入员工薪水范围,返回员工工号、姓名、薪水结果集,结果集按员工薪水升序排列。(15 分)
——-第四题答案
SQL create or replace procedure p_employee
2 (iminsalary in number, 3 imaxsalary in number) 4 is
begin
for x in(select id,salary,name from(select * from employee where salary between iminsalary and imaxsalary) order by salary)
loop
dbms_output.put_line(to_char(x.id)||to_char(x.salary)||x.name);
end loop;
end;
11 /
过程已创建。
SQL exec p_employee(2000,2007); 502000 王明 50
512001 王明 51
522002 王明 52
532003 王明 53
542004 王明 54
552005 王明 55
562006 王明 56
572007 王明 57
PL/SQL 过程已成功完成。
创建函数 f_employee 实现更新员工薪水的功能,将薪水低于 2000 且姓 wang 的员工薪水加 5%,其他不变,更新成功则返回 0,否则返回 1。(15 分)
———第五题答案
SQL create or replace fun
您可能关注的文档
- 8 印刷 根据要求画出电路图.docx
- 8、模拟两对相对性状测交的实验P18.docx
- 8A M1 U1分析和总结分析和总结.docx
- 8AUnit8Naturaldisasters知识点分析和总结.docx
- 8A第一单元分析和总结.docx
- 8B C6 同步练习 牛津英语.docx
- 8D报告格式分析和总结.docx
- 8大技巧教你直通车如何养词.docx
- 8的乘法口诀教案.docx
- 8的乘法口诀教学设计.docx
- 中国行业标准 GM/T 0126-2023HTML密码应用置标语法.pdf
- 《JJF 2121-2024恒转速源校准规范》.pdf
- 餐饮服务中20条处理要点.docx
- 《GM/T 0011-2023可信计算 可信密码支撑平台功能与接口规范》.pdf
- 《JJF 2134-2024旋转流变仪校准规范》.pdf
- JJF 2121-2024恒转速源校准规范.pdf
- 计量规程规范 JJF 2121-2024恒转速源校准规范.pdf
- 《JJF 2118-2024压力式六氟化硫气体密度控制器校验仪校准规范》.pdf
- JJF 2134-2024旋转流变仪校准规范.pdf
- 计量规程规范 JJF 2134-2024旋转流变仪校准规范.pdf
文档评论(0)