oracle 上机考试试题与答案
更新时间:2024-01-13 12:47:01 阅读量: 教育文库 文档下载
- oracle数据库推荐度:
- 相关推荐
1、写一个pl/sql程序块:直接使用数据类型定义两个变量v_empno和v_ename,从scott模式下的emp表中检索某个员工的编号empno和姓名ename,存储到v_empno和v_ename,并输出此员工的编号和姓名。
set serveroutput on declare
type merchandise is record( v_empno number(30), v_ename varchar2(30));
record_merchandise merchandise; begin
select empno,ename into record_merchandise from emp
where empno='7369';
dbms_output.put_line(record_merchandise.v_empno); dbms_output.put_line(record_merchandise.v_ename); end;
2、写一个pl/sql程序块:根据scott模式下的emp表中的部门编号deptno字段的值,为姓名为SCOTT的雇员修改工资;若他所在部门号为10,则工资加100;若部门号为20,则工资加300;否则工资加400。
set serveroutput on declare
v_deptno emp.deptno%type; addsal emp.sal%type; sal number;
begin
select deptno into v_deptno from emp where ename='SCOTT'; if v_deptno='10' then addsal:=100;
elsif v_deptno='20' then addsal:=300; else addsal:=400; end if;
update emp set sal=sal+addsal where ename='SCOTT'; dbms_output.put_line(sal); end;
3、写一个pl/sql程序块:定义一个游标类型type_cursor,然后使用type_cursor定义变量ref_cur;根据scott模式下的emp表和dept表,使用游标变量ref_cur检索员工姓名和工作信息,并输出员工姓名和工作信息;使用游标变量ref_cur检索部门编号和部门名称信息,并输出部门编号和部门名称信息。
set serveroutput on declare
type type_cursor is ref cursor; ref_cur type_cursor; mer_rec emp%rowtype; ner_rec dept%rowtype; begin
open ref_cur for select ename,job from emp; loop
fetch ref_cur into mer_rec; exit when ref_cur%notfound; dbms_output.put(mer_rec.ename ||' '); dbms_output.put(mer_rec.job );
end loop;
open ref_cur for select deptno,dname from dept; loop
fetch ref_cur into ner_rec; exit when ref_cur%notfound; dbms_output.put(ner_rec.deptno||' '); dbms_output.put(ner_rec.dname ); end loop; close ref_cur; end;
4、写一个pl/sql存储过程:根据scott模式下的emp表,写一个带参数的存储过程proc(deptno in number,sun_sal out number),输入部门编号,输出该部门的总工资信息。并写一个pl/sql程序块,测试该存储过程。
create or replace procedure searchmerch ( v_deptno in number,
sun_sal out number) is begin
select 12*(sal+nvl(comm,0)) into sun_sal from emp
where deptno=v_deptno; exception
when no_data_found then sun_sal:='0'; end;
5、写一个pl/sql程序块:根据scott模式下的emp表和dept表,输出每个部门的编号和部门名称,以及该部门下所有的雇员和雇员工资,及其该部门的总人数。 输出效果如下:
部门编号:-- 部门名称:-- 雇员姓名:-- 雇员工资:-- 该部门总人数:--
declare
CURSOR c_dept IS SELECT deptno,dname FROM dept ORDER BY
deptno;
CURSOR c_emp (p_dept VarCHAR2) IS
SELECT ename,sal FROM emp WHERE deptno=p_dept ORDER BY ename; n number; BEGIN
FOR r_dept IN c_dept LOOP
DBMS_OUTPUT.PUT_LINE('部门编号:'|| r_dept.deptno||'--部门名 称:'||r_dept.dname); n:=0;
FOR r_emp IN c_emp(r_dept.deptno) LOOP
DBMS_OUTPUT.PUT_LINE('雇员姓名: '||r_emp.ename || ' 雇员工资:'||r_emp.sal); n:=n+1; END LOOP;
DBMS_OUTPUT.PUT_LINE(r_dept.dname||'部门的总人数:'|| n); END LOOP; END;
6.创建一个语句级触发器CHECK_TIME,限定对表EMP的修改时间为周一至周五的早8点至晚5点。
create or replace trigger CHECK_TIME before update or insert or delete on emp begin
if (to_char(sysdate,'DY') in ('sat','sun')) or to_char(sysdate,'HH24')<'08' or to_char(sysdate,'HH24')>='17' then
raise_application_error(-20500,'只能在工作时间对表操作!'); end if; end;
正在阅读:
oracle 上机考试试题与答案01-13
园林室外铺装简介 - 图文10-27
质量管理的开题报告05-03
全国高等学校计算机等级考试(广东)2005年秋季试题205-19
国寿产险(备案)N137-船舶保险附加战争、罢工保险条款05-31
2016春中央电大本科计算机应用基础网考操作题及答案-112-25
- exercise2
- 铅锌矿详查地质设计 - 图文
- 厨余垃圾、餐厨垃圾堆肥系统设计方案
- 陈明珠开题报告
- 化工原理精选例题
- 政府形象宣传册营销案例
- 小学一至三年级语文阅读专项练习题
- 2014.民诉 期末考试 复习题
- 巅峰智业 - 做好顶层设计对建设城市的重要意义
- (三起)冀教版三年级英语上册Unit4 Lesson24练习题及答案
- 2017年实心轮胎现状及发展趋势分析(目录)
- 基于GIS的农用地定级技术研究定稿
- 2017-2022年中国医疗保健市场调查与市场前景预测报告(目录) - 图文
- 作业
- OFDM技术仿真(MATLAB代码) - 图文
- Android工程师笔试题及答案
- 生命密码联合密码
- 空间地上权若干法律问题探究
- 江苏学业水平测试《机械基础》模拟试题
- 选课走班实施方案
- 上机
- 考试试题
- 答案
- oracle
- 正电子湮灭
- 改制生农村道路交通事故调查分析调研报告
- 创建学习型家庭读书汇报会教案
- 土力学名词解释+简答复习题
- 试析法治理念在武警部队建设中的确立
- 2010高考语文试卷及答案详解 全国卷2 - 图文
- 二年级-下册写字教案进度表
- 七年级语文上册 28 女娲造人导学案(无答案)(新版)新人教版
- 电气设备检修规程
- 2007年二级建造师《专业工程管理与实务-建筑工程》真题和答案(选择题)
- 2015安阳市直卫生事业单位招聘考试备考资料之医学常识要点总结四十九
- 2012全国中考物理试题分类汇编(100套)透镜及其应用
- 2018-2024年中国磁粉探伤检测器行业市场运营态势报告(目录) - 图文
- 毕业设计说明书(周瑜工艺及夹具) - 图文
- 2012北京朝阳区初三物理一模试题及答案(电子版)免费下载
- 安阳实验小学:中高段小学数学“预习导学”的实践研究
- 土方平衡方案
- 税收筹划复习思考题1
- 房地产企业涉税风险点及筹划案例提示
- 论文观点