51CTO下载-一道Oracle笔试题附网友答案.doc

51CTO下载-一道Oracle笔试题附网友答案.doc

  1. 1、本文档共10页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
51CTO下载-一道Oracle笔试题附网友答案

一道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 — 姓名 ); 1.创建序列seq_employee,该序列每次取的时候它会自动增加,从1开始计数,不设最大值,并且一直累加,不循环。(10分)SQL Create sequence seq_employee increment by 1 start with 1 nomaxvalue nocycle; 序列已创建。 2.写一个PL/SQL块,插入表user.employee中100条数据。插入该表中字段id用序列seq_employee实现,薪水和姓名字段可以任意填写。(15分) SQL declare i number; 2 begin 3 for i in 1 .. 100 4 loop 5 insert into employee 6 values(seq_employee.nextval,1950+i,’王明’||to_char(i)); 7 commit; 8 end loop; 9 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行。 3.写一个语句块,在语句块中定义一个显式游标,按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; 4 begin 5 open c; 6 loop 7 fetch c into v_record; 8 exit when c%notfound; 9 dbms_output.put_line(to_char(v_record.id)||’,||to_char(v_record.salary)||’,||v_record.name); 10 end loop; 11 close c; 12 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 过程已成功完成。 4.创建存储过程p_employee,输入员工薪水范围,返回员工工号、姓名、薪水结果集,结果集按员工薪水升序排列。(15分) ——-第四题答案 SQL create or replace procedure p_employee 2 (iminsalary in number, 3 imaxsalary in number) 4 is 5 begin 6 for x in(select id,salary,name from(select * from employee where salary between iminsalary and imaxsalary) order by salary) 7 loop 8 dbms_output.put_line(to_char(x.id)||to_char(x.salary)||x.name); 9 end loop; 10 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 过程已成功完成。 5.创建函数f_employee实现更新员工薪水的功能,将薪水低于2000且姓wang的员工薪水加5%,其他不变,更新成功则返回0,否则返回1。(15分) ———第五题答案 SQL create or replace function f_employee r

文档评论(0)

xcs88858 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

版权声明书
用户编号:8130065136000003

1亿VIP精品文档

相关文档