《Oracle作业及其答案.ppt》由会员分享,可在线阅读,更多相关《Oracle作业及其答案.ppt(22页珍藏版)》请在人人文库网上搜索。

1、第3章作业,编写SQL语句完成下列功能,并要求写出第1、3、7题的 查询结果。 1 查询10号部门员工的员工号以及其领导的员工号,并以别名“领导员工号”显示列名。 select empno,mgr 领导员工号 from emp where deptno=10; 2 查询emp表中所有的员工信息,并要求按照部门号升 序排序,相同部门按照工资降序排序。 select * from emp order by deptno,sal desc,1,3 查询部门内部人数多于3人的部门号。 select deptno,count(*) from emp group by deptno having coun。

2、t(*)3; 4 向emp表中插入一条数据,员工号1000,员工名: Zhangsan,工作日期是1985年2月3日。 insert into emp(empno,ename,hiredate) values (1000,Zhangsan,date1985-2-3); 5 修改Zhangsan的工资为20部门的最高工资。 update emp set sal=(select max(sal) from emp where deptno=20) where ename=Zhangsan,2,6 删除员工名中包含一个“A”并且以“W”结尾的 员工信息。 delete from emp where 。

3、ename like %A%W; 7 统计emp表中每个部门的平均工资和最高工资,并 要求参与统计的部门的平均工资多于1000,少于3000。 select avg(sal),max(sal) from emp group by deptno having avg(sal) between 1000 and 3000,3,第5章作业,编写sql语句完成下面功能。 1、按照下列表结构创建表,class表,create table class( cno number(2) constraint pk_cl primary key, cname varchar2(20,4,student表,crea。

4、te table student( sno number(4) constraint pk_stu primary key, sname varchar2(20) constraint un_stu unique, sage number, sex char(2), cno number(2,5,2、为student表添加外键约束,其cno列参照class表cno列。 alter table student add constraint fk_stu foreign key(cno) references class(cno); 3、为student表sage列添加检查约束,列值在0-100。。

5、 alter table student add constraint ck_stu check(sage between 0 and 100); 4、为student表sex列添加约束,确定其值为F或M,且默认值为M。 alter table student add constraint ck_stu1 check(sex in (F,M); alter table student modify sex default M,6,5、查询student表的约束信息,并记录查询结果。 select constraint_name,column_name from user_cons_column。

6、s where table_name=STUDENT; select owner,constraint_name,constraint_type,status from user_constraints where table_name= STUDENT,7,已知表: 学生表:student(sno,sname,sbirth,sclass) 班级表:class(cno,cname,cdept) 系表:department(dno,dname) 其中student(sclass)关联class(cno), class(cdept)关联department(dno,第6章作业,8,编写sql语句完。

7、成下列功能。 1.查询班级名为1班的所有学生的学号、姓名。 select sno,sname from student a,class b where a.sclass=o and cname=1班; 2.查询学号为20070001的学生的姓名和所在班的班名以及所在系的系名。 select sname,cname,dname from student a,class b,department c where a.sclass=o and b.cdept=c.dno and a.sno=20070001,9,3.查询计算机系里1988年以前出生的学生的学号和出生日期。 1) select sno。

8、,sbirth from student where sclass in (select cno from class a,department b where a.cdept=b.dno and d.dname=计算机系 ) and sbirthdate1988-01-01; 2) select sno,sbirth from student a,class b,department c where a.sclass=o and b.cdept=c.dno and d.dname=计算机系 and a.sbirthdate1988-01-01,10,4.查询比计算机系某一个班的年龄小的学生的。

9、学号和出生日期。 select sno,sbirth from student where sbirth any (select sbirth from student a,class b,department c where a.sclass=o and b.cdept=c.dno and d.dname=计算机系); 5.查询计算机系各个班的人数,显示人数和班级号。 select count(*),sclass from student where sclass in (select cno from class a,department b where a.cdept=b.dno and。

10、 b.dname=计算机系,11,1.定义记录表类型存储dept表中每个部门(10、20、30、40)的部门号和部门名,并输出。 set serveroutput on declare type table_dept is table of dept%rowtype index by binary_integer; t_d table_dept; begin for t_d in (select deptno,dname from dept) loop dbms_output.put_line(t_d.deptno|t_d.dname); end loop; end,第7章 作业,12,2.利。

11、用显式游标修改表emp中各个雇员的工资,若雇员属于10号部门,则增加100,若雇员属于20号部门,则增加200,否则增加300。 declare cursor c_emp is select empno,sal,deptno from emp; begin for vc in c_emp loop if vc.deptno=10 then update emp set sal=sal+100 where empno=vc.empno; elseif vc.deptno=20 then update emp set sal=sal+200 where empno=vc.empno; else u。

12、pdate emp set sal=sal+300 where empno=vc.empno; edn if; end loop; end,13,3.查询并输出emp表中某一部门的员工号、员工名。如果此部门号不存在,捕获此异常。如果出现其他异常,给出异常信息。 declare type r_emp is record( ENO emp.empno%type, ENAME emp.ename%type); type emp_rc is ref cursor return r_emp; v_rc emp_rc; emp_row r_emp; v_deptno emp.deptno%type; ex。

13、 exception; i number:=0; j number:=0; begin,14,v_deptno,15,exception when ex then dbms_output.put_line(此员工不存在); when others then dbms_output.put_line(异常信息:|SQLCODE|SQLERROM); end,16,第7章练习,ex:使用游标与异常处理,完成下列功能。 查询dept表中的所有部门号与部门名,并输出。 将dept表中部门号为50的部门地址loc改为:上海。 如果部门号不合法,则给出错误提示。 如果出现其他错误,给出错误代码和错误文本,。

14、17,declare cursor e1 is select * from dept; ex_update exception; begin for ve in e1 loop dbms_output.put_line(ve.deptno| |ve.dname); end loop; update dept set loc=上海 where deptno=50; if sql%notfound then raise ex_update; end if; exception when ex_update then dbms_output.put_line(没有50号部门); when other。

15、s then dbms_output.put_line(sqlcode| |sqlerrm); end,18,19,第8章作业,1、编写过程,用于查询某部门的所有员工的员工号和工资。如果部门号不存在,提示出错。 create or replace procedure searchempno_sal(v_dno number) as cursor c_emp is select empno,sal from emp where deptno=v_dno; cc c_emp%rowtype; ex exception; begin open c_emp; fetch c_emp into cc; 。

16、if c_emp%notfound then raise ex; else dbms_output.put_line(员工号|cc.empno); dbms_output.put_line(工资|cc.sal,end loop; end if; close c_emp; exception when ex then dbms_output.put_line(此部门号不存在); when others then dbms_output.put_line(捕获到其他异常); end searchempno_sal,20,2、编写函数,查询某个部门所有员工的工资和。 create or replac。

17、e function sum_sal(dno dept.deptno%type) return number as sum_sal number; begin select sum(sal) into sum_sal from emp where deptno=dno; return sum_sal; end sum_sal,21,3、编写PL/SQL块调用1、2题中的过程和函数。查询并输出10号部门的员工号、工资和工资和。 set serveroutput on declare v_sum_sal number; begin searchempno_sal(10); v_sum_sal:=sum_sal(10); dbms_output.put_line(10号部门的工资和为:|v_sum_sal); end,22。

oracle所有作业的答案,Oracle作业及其答案.ppt相关推荐

  1. 【ORACLE 高可用】 作业 :配置ORACLE GoldenGate 1

    1.配置好OGG,贴出配置的整个过程. 2.画一个OGG数据复制的数据流图. 3.OGG有哪些进程,都有什么作用? 4.OGG数据复制的机制是什么,画出示意图. =================== ...

  2. 电大计算机2019作业,【电大题】2019年最新国家开 放大学电大《人文英语2、3、》网络核心课形考网考作业两套汇编附全答案.docx...

    [电大题]2019年最新国家开 放大学电大<人文英语2.3.>网络核心课形考网考作业两套汇编附全答案.docx 文档编号:768065 文档页数:61 上传时间: 2019-10-17 文 ...

  3. 下面使用计算机动画制作的,2020年最新电大《计算机二维动画制作》形考作业任务01-03网考试题及答案(10页)-原创力文档...

    最新电大<计算机二维动画制作>形考作业任务1-3网考试题及答案 1%通过 考试说明<计算机二维动画制作>形考共有3个任务.做考题时,利用本文档中的查找工具,把考题中的关键字输到 ...

  4. oracle 在数据库打开状态下进行备份时_下面描述不正确的是,Oracle数据库DBA面试题50道及答案_经典...

    Oracle数据库DBA面试题50道及答案_经典 1. 解释冷备份和热备份的不同点以及各自的优点 解答:热备份针对归档模式的数据库,在数据库仍旧处于工作状态时进行备份.而冷备份指在数据库关闭后,进行备 ...

  5. 计算机应用技术基础 形考4,最新电大《计算机应用技术基础》形考作业任务01-03网考试题及答案...

    最新电大<计算机应用技术基础>形考作业任务01-03网考试题及答案 最新电大<计算机应用技术基础>形考作业任务01-03网考试题及答案 100%通过 考试说明:<计算机应 ...

  6. 2022内蒙古最新建筑施工塔式起重机(建筑特种作业)模拟考试题库及答案

    百分百题库提供特种工(塔式起重机)考试试题.特种工(塔式起重机)考试预测题.特种工(塔式起重机)考试真题.特种工(塔式起重机)证考试题库等,提供在线做题刷题,在线模拟考试,助你考试轻松过关. 123对 ...

  7. 【MOOC】华中科技大学操作系统慕课答案-单元作业+第1~2章开放性思考题

    单元作业答案如果没大问题的话,多半是直接摘抄自PPT. 文章目录 第一章 操作系统概述 单元作业(1) 开放性思考题 第二章 操作系统逻辑结构 单元作业 开放性思考题 第三章 操作系统用户界面 单元作 ...

  8. 互动作业组的计算机在哪,互动作业如何找答案 互动作业搜答题教程

    互动作业是一款解题软件,帮助中小学生在课外时间.没有老师答疑时学习解题方法,攻破难题知识点,一些小伙伴想知道互动作业如何找答案,下面就让小编为大家介绍一下互动作业搜答题教程,感兴趣的小伙伴一起来看一看 ...

  9. 2019年高压电工作业安全生产模拟考试题库及答案

    2019年高压电工作业安全生产模拟考试题库及答案 题库来源:安全生产模拟考试一点通 第1题.[判断题] 三相交流对称电路中,如采用三角形接线时,线电流等于相电流的根号3倍. A.正确 B.错误 正确答 ...

  10. oracle面试题答案,Oracle面试题笔试题及参考答案

    一套Oracle面试题笔试题及参考答案 Oracle, 笔试, 面试 完成下列操作,写出相应的SQL语句 1.创建表空间neuspace,数据文件命名为neudata.dbf,存放在d:\data 目 ...

最新文章

  1. 轻量级图卷积网络LightGCN介绍和构建推荐系统示例
  2. 程序员 :超越软件蓝领的七种武器
  3. 带你了解什么样的信息是陷阱或为勒索病毒在诱骗
  4. 一、史上最强hadoop分布式集群的搭建
  5. boost::intrusive::sg_set用法的测试程序
  6. 配置yum,nc,telnet
  7. Eclipse,MyEclipse 安装SVN插件
  8. 如何使用Bootstrap Modal和jQuery AJAX创建登录功能
  9. iOS开发中的单元测试(三)——URLManager中的测试用例解析
  10. [排错] Status error 2850
  11. Bailian3704 扩号匹配问题【堆栈】
  12. 智能水电表远程管理系统
  13. macOS 内置的端口扫描工具
  14. 空城计课件软件测试,空城计课件公开课.ppt
  15. cocos2dx游戏-可爱的小精灵的各种用法大全
  16. 华为荣耀路由器虚拟服务器,荣耀路由器怎么设置?
  17. 代码随想录01 | 704二分查找和27移除元素
  18. 上传到linux服务器上的EXCEL、图片、文件地址获取不同
  19. 单片机应用系统设计技术——单片机电梯控制器
  20. simulink中子系统分解

热门文章

  1. python打印空心正方形
  2. 锥台上收发振子天线的隔离度
  3. NSProxy使用笔记
  4. thinkphp rabc权限总结
  5. compser安装遇到的问题
  6. cesium加载CAD模型(.dwg)
  7. 房奴车奴孩奴,月薪过万业不过如此!
  8. 山石防火墙重置密码教程
  9. php面试英文自我介绍范文带翻译,外企面试英语自我介绍优秀范文三篇
  10. 对数坐标归一化_数据预处理-归一化/数据转换