数据库oracle-第二次作业

合集下载

Oracle数据库第二次PPT课件

Oracle数据库第二次PPT课件
能只与主键的某一部分相关(主要针对联合主键而言)。 • 也就是说在一个数据库表中,一个表中只能保存一种数据,
不可以把多种数据保存在同一张数据库表中。
• 联合主键:就是用2个或2个以上的字段组成主键。
7
第二范式
• 这样就产生一个问题:这个表中是以订单编号和商品编号作 为联合主键。这样在该表中商品名称、单位、商品价格等信 息不与该表的主键相关,而仅仅是与商品编号相关。所以在 这里违反了第二范据库的安全性和完整性。 2. 检测并改善数据库性能。 3. 增加新的功能。 4. 修改错误。
15
16
理解Oracle RDBMS和Oracle SQL 内容回顾:
Oracle的SQL实现在很大程度上符合ANSI标准,但并非百分 之百地兼容。Oralce的竞争对手也并未做到与该标准完全兼容。
1
2.1 数据库的逻辑设计 2.1.1 关系数据库设计基础 2.1.2 关系数据库规范化 1. 第一范式 2. 第二范式 3. 第三范式
2.2 数据库的物理设计
2.3 数据库实施
2.4 创建数据库
2
几个重要概念
实体标识符:能够将一个实体与其他实体区别开来的属性集。 表: 实体的集合。 实体: 表中的行。 属性: 表中的列。
10
第三范式
• 比如在设计一个订单数据表的时候,可以将客户编号作 为一个外键和订单表建立相应的关系。而不可以在订单 表中添加关于客户其它信息(比如姓名、所属公司等) 的字段。如下面这两个表所示的设计就是一个满足第三 范式的数据库表.
外键:如果关系模式R中的某属性集不是R的主键,而是另一个关系R1的主键则该 属性集是关系模式R的外键,通常在数据库设计中缩写为FK
• 而如果把这个订单信息表进行拆分,把商品信息分离到另一 个表中,就非常完美了。如下面这两个所示。

第二次大型数据库技术作业

第二次大型数据库技术作业

第二次按要求完成下列操作(写出具体的语句)(1)SYS用户(密码为123456)在CMD下以DBA身份登陆(2)创建临时表空间user_temp; 文件D:\oracle\oradata\Oracle9i\user_temp.dbf初始大小50M,可以自动扩展,每次增加50M,最大大小为无限制,为本地管理方式的表空间。

(3)创建数据表空间test_date,文件D:\oracle\oradata\Oracle9i\user_data.dbf,初始大小50M,可以自动扩展,每次增加50M,最大大小为20480M,为本地管理方式的表空间。

(4)建立表空间data01,文件d:\oracle\oradata\d\DA TA01.dbf,初始大小500M,区的大小统一为128K(5)建立UNDO表空间UNDOTBS02,文件d:\oracle\oradata\db\UNDOTBS02.dbf,初始大小50M(6)使表空间data01脱机,且在意外删除了数据文件时可恢复(7)使表空间data01联机(8)使表空间data01只读(9)删除表空间data01及其中的对象和相应的操作系统文件第三次按要求完成下列操作(写出具体的语句)1.查看表空间的数据文件2.在表空间test_data增加数据文件d:\oracle\radata\db\GAME02.dbf,初始大小50M3.使表空间test_data的文件d:\oracle\oradata\db\GAME02.dbf大小变为4000M4.使表空间test_data的文件d:\oracle\oradata\db\GAME02.dbf可以自动扩展,每次增加100M,最大尺寸为100000M5.创建数据表空间sample,文件D:\ORACLE\ORADATA\ORA92\SAMPLE.ora,初始大小5M, 为本地管理方式的表空间,区的大小为统一大小,段空间管理为自动。

数据库oracle-第二次作业

数据库oracle-第二次作业

完成满分1.00题干以下哪个段可以进行自动管理?()选择一项:a. ROLLBACKb. INDEXc. CACHEd. TEMPORARY题目2完成满分1.00题干回滚段的作用有()。

选择一项:a. 数据库恢复b. 数据的读一致性c. 事务回滚d. 以上都是题目3完成题干以下哪个不属于Oracle的内存结构?()选择一项:a. 全局系统区b. 用户区c. 软件代码区d. 排序区题目4完成满分1.00题干如果没有指定临时表空间,以下哪个将作为临时表空间?()选择一项:a. INDEXb. USERSc. SYSTEMd. TEMP题目5完成满分1.00题干SGA是由以下哪些项组成的()。

选择一项:a. Redo Log Bufferb. Buffer Cachec. Shared Poold. 以上都是题目6完成满分1.00题干段的集合叫做()。

选择一项:a. 区b. 段c. 数据库d. 表空间题目7完成满分1.00题干常见的后台进程LGWR的作用是()。

选择一项:a. 日志写入程序b. 归档c. 进程监控d. 数据库写入程序题目8完成满分1.00题干以下哪个不是系统创建的表空间名称?()选择一项:a. 临时表空间b. SYSAUX表空间c. 用户表空间d. SYSTEM表空间题目9完成满分1.00题干数据库运行状态下,以下哪个表空间必须是联机状态?()选择一项:a. SYSTEMb. TEMPORARYc. USERSd. ROLLBACK题目10完成满分1.00题干直到以下哪个操作完成后,Oracle才认为事务已经提交?()选择一项:a. 事务所做的修改已由LGWR进程成功写入Redo Log 文件b. SMON进程提交了对数据所做的修改c. 被修改的数据已由DBWR进程写入磁盘d. PMON进程提交了对数据所做的修改题目11完成满分1.00题干Oracle中管理用户会话连接的进程是()。

选择一项:a. PMONb. NET8c. SMONd. SERV题目12完成满分1.00题干数据字典表和视图存储在()中。

《Oracle数据库应用与实践》课后习题参考答案

《Oracle数据库应用与实践》课后习题参考答案

第 5 章 Oracle 模式对象
一、填空题
1. 字段级约束 表约束
2. NOT NULL 约束 UNIQUE 约束 PRIMARY KEY 约束

3. CREATE TABLE
CREATE ANY TABLE
4. UNIQUE PRIMARY KEY CHECK
5. 合并索引 重建索引
6. user_updatable_columns
一、 填空题 1. 数据挖掘 隐含的 未知的 2. API-ODM Java API ODM DBMS_DM PL/SQL API
3. Clustering Association Feature Extraction
Oracle 数据库应用与实践
2、某 cc 表数据如下: c1 c2 -------------1西 1安 1的 2天 2气
Oracle 数据库应用与实践
3好 …… 转换为 1 西安的 2 天气 3好 要求:不能改变表结构及数据内容,仅在最后通过 SELECT 显示出这个查询结果
代码为: create or replace function x return varchar2 is type t_array is table of number index by binary_integer; type tarray is table of varchar2(10) index by binary_integer; ta t_array; tar tarray; re varchar2(10); n number; na varchar2(10); begin select id bulk collect into ta from (select id,name from xx order by id) group by id; for i in st loop dbms_output.put(ta(i)||' '); select name bulk collect into tar from xx where id=ta(i); for i in st loop dbms_output.put(tar(i)); end loop; dbms_output.put_line(' '); end loop; return re; end;

oracle第二次考试

oracle第二次考试

一、有一个Oracle数据库,数据库中包括三个表:(1)“学生”表Student由学号(Sno)、姓名(Sn)、性别(Ssex)、年龄(Sa)、所在系(Sd)五个属性组成(2)所以系的对应值:“计算机系”1、“机械工程系”2、“法学系”3、“工程物理”4 (3)“课程”表Course由课程号(Cno)、课程名(Cn)、学分(Ccredit)三个属性组成(4)“学生选课”表SC由学号(Sno)、课程号(Cno)、成绩(Grade)三个属性组成请解答如下问题:1.统计各系各年龄段的学生人数(需要显示系的名称)、年龄段分为(20以下、20-24、其他)2.统计各系不及格同学与及格同学数量的比例,不考虑全都不及格和全都及格的情况,(可以使用两个视图来实现)3.显示张三的所有课程以及其成绩信息4.显示所有学生已经完成的学分,(课程成绩大于60分获得课程的学分)5.创建一个存储教程A,功能是修改SC表中的成绩为60,条件是成绩大于58分并小于60分,要求在出现异常的情况数据库能够回滚6.Servlet在web.xml中的配置7.JDBC手工控制事务的提交和回滚的实现8.类型转换,java.util.DA TE的对象A转换成ng.String的YYYY-MM-DD的日期,并显示出来9.在javascript中提交一个form,需要指定action、target(判断form中文本框1不能为空,文本框2不能为字符)10.Tomcat中连接池的server.xml中需要定义哪些内容二、1 数据库中的表A(NAME char(10),GRADE int)中有如下内容:NAME GRADEAAAA 80BBBB 60CCCC 70表B(NAME char(10),age int)中有如下内容:NAME AGEAAAA 26BBBB 24CCCC 26DDDD 26写一SQL语句,得到下面的查询结果:NAME GRADE AGEAAAA 80 26BBBB 60 24CCCC 70 26DDDD NULL 26A表和B表关联,根据NAME用A表的GRADE值更新B表的AGE字段,运行后B表的内容为AAAA 60BBBB 80CCCC 86DDDD 24(1)关联A表B表根据姓名相同(NAME)按年龄(AGE)分组求出不同的年龄的平均成绩(GRADE),要求写出SQL语句,并要求写出结果。

ORACLE数据库测试2及答案

ORACLE数据库测试2及答案

1、表中的约束有哪些?请举例说明。

答:①primary key:学生表的学号②foreign key:成绩表的学号③check:性别in(‘男’,’女’)④not null:学生表的姓名⑤default:订购单订购日期为系统时间⑥unique:学生表中若学号为主键,ID号用unique2、引用索引的原则是什么?P84答:①在表中插入数据后创建索引②索引正确的表和列③合理安排索引列④限制表中索引的数量⑤制定索引数据块空间⑥根据索引大小设置存储参数。

3、简要说明用户、角色和权限之间的关系。

P172答:角色是一组权限,可授予用户或其他角色。

可利用角色来管理数据库权限,可将权限添加到角色中,然后将角色授予用户。

用户可使该角色起作用,并实施角色授予的权限。

一个角色包含所有授予角色的权限及授予它的其他角色的全部权限。

4、oracle的逻辑结构是如何组织的?答:作业中有二、用PL/SQL编程,计算S=1/2+1/4+1/8+…+1/2ⁿ,S精确到万分之一。

解:declaren number:=2;S number:=0;beginloopS:=S+1/n;n:=n*2;if 1-S<=(1/10000) thendbms_output.put_line(S);exit;end if;end loop;end;三、编写存储过程,求指定某门课程(课程名)的平均分数。

解:create or replace procedure proc(kcm in carchar2)avg1 number;beginselect AVG(成绩) as 平均分into avg1 from CJB where 课程号in (select 课程号from KCB where 课程名=kcm and rownum=1);dbms_output.put_line(avg1);end;四、编写触发器,向成绩表中插入一条记录,检查学生是否在学生表中存在,若不存在,则取消该操作。

Oracle实验报告2答案

Oracle实验报告2答案

Oracle实验报告2答案《Oracle数据库技术》实验指导书2基本SELECT、WHERE和ORDER BY子句的使用实验要求1)掌握SQL*PLUS的基本使用.2)掌握SELECT语句的简单用法.3)掌握WHERE子句的用法。

4)掌握ORDER BY子句的用法。

实验步骤(1)登录到SQL*Plus,初始用户名:SCOTT,口令为TIGER。

(2)分别显示EMP﹑DEPT﹑SALGRADE表结构,并查看表中的数据.(3)创建一个查询显示每个雇员的姓名﹑工作﹑受雇日期及雇员编号,并且要将雇员编号作为第一列显示,最后将该SQL语句保存成文件plql.sql,并执行该脚本文件。

(4)将脚本文件plql.sql调取到SQL缓冲区,并将列标题设置为Emp #,Employee,Job及Hire Date,将SQL语句保存成文件plq2.sql,最后返回查询结果。

(5)创建一个查询显示工资大于2850美元的姓名及工资。

将该查询保存成脚本文件p2q1.sql,并执行该文件。

(6)修改脚本文件p2q1.sql,显示工资不在1500到2850美元之间的雇员的姓名及工资,并以p2q2.sql文件重新保存该查询。

(7)修改文件p2q2.sql,显示在10和30部门工作并且工资大于1500美元的雇员的姓名和工资,列标题显示为Employee和MonthlySalary,最后以p2q3.sql重新保存该文件,返回查询结果。

(8)修改脚本文件p2q3.sql显示奖金比工资多10﹪以上的雇员的姓名﹑工资及奖金。

将该查询保存成p2q4.sql脚本文件,并返回查询结果。

思考练习题1.下面的SELECT语句能成功执行吗?SQL>SELECT ename, job, sal Salary2 FROM emp;可以执行!2.下面的语句有三处错误,请纠正它们.SQL>SELECT empno,ename2 salary *12 ANNUAL SLARY3 FROM emp;3.创建一个查询EMP表中检索出不重复的工作名称4.创建一个查询显示雇员编号为7566 的雇员的姓名和部门编号。

oracle考试题目及答案2

oracle考试题目及答案2

Database Design Section 2(回答此部分的所有问题)1.关系名称通常是动词。

请判断对错。

标记为待复查 (1) 分数对 (*)错正确2.易变属性有特殊要求,在进行数据建模时需要特别注意。

请判断对错。

标记为待复查 (1) 分数对 (*)错正确Database Design Section 3 (回答此部分的所有问题)3.关系基数很重要。

请判断对错。

标记为待复查 (1) 分数对 (*)错正确4.两个实体之间只能有一种关系。

请判断对错。

标记为待复查 (1) 分数对错 (*)正确Database Design Section 4 (回答此部分的所有问题)5.“其它”子类型是必需的。

请判断对错。

标记为待复查 (1) 分数对错 (*)正确Database Design Section 4(回答此部分的所有问题)6.一个父类型只能有一个子类型。

请判断对错。

标记为待复查 (1) 分数对错 (*)正确7.对于表明女孩和男孩不能在一起上课的业务规则,您将如何建模?标记为待复查 (1) 分数使用一个父类型父类型“学生”有两个子类型“男孩”和“女孩”,这两个子类型都与“性别”相关,而“性别”又与“班级”相关 (*)使属性“性别”成为必需的无法对此进行建模。

您需要记录此规则正确Database Design Section 5 (回答此部分的所有问题)8.交集实体经常有涉及 UID 的关系,因此,这些关系经常被限定。

请判断对错。

标记为待复查(1) 分数对 (*)错不正确。

请参阅第 5 部分第 3 课。

9. 如果两个实体之间存在两种关系,这些关系可能是_____________或_____________。

标记为待复查(1) 分数冗余关系或必需关系 (*)重复关系或必需关系丰富型关系和真正良好关系冗余关系和重复关系正确10.不可转移的关系意思是说可以更改详细资料使其指向新的主表。

请判断对错。

标记为待复查 (1) 分数对错 (*)正确Database Design Section 6(回答此部分的所有问题)11.什么情况下实体才符合第二范式?标记为待复查 (1) 分数所有非 UID 属性依赖于整个 UID 。

oracle作业(答案另附)

oracle作业(答案另附)

Oracle 作业:
现有如下两张表,请编写Sql脚本,分别完成
1.从表1获取数据,格式化输出为表2。

2.从表2读取数据,格式化输出为表1。

自己创建所需表,视图,及数据等相应脚本(请参考试验1-3)。

表 1
STUDNAME COURSENAME CSCORE USCORE
-------------------------------- - ------------------ ---------- ----------
李白摔跤80 1
李白军事理论60 5
李白数学70 3
杜甫摔跤95 1
杜甫军事理论85 5
杜甫数学75 3
李清照摔跤45 1
李清照军事理论55 5
李清照数学50 3
蔡琰摔跤25 1
蔡琰军事理论15 5
蔡琰数学10 3
表2
姓名摔跤军事理论数学总学分
-------------------------------- ------------------ ---------- ---------- ----------
李白80 60 70 9
杜甫95 85 75 9
李清照45 55 50 9
蔡琰25 15 10 9
作业要求:
1只需要相应脚本,文件名称为姓名学号.sql
2 脚本关键语句最好有注释
3 要求至少6月13号(第16周周四之前上交只需要电子版本,上交给学委,请学委压缩后给我,逾期不再受理。


4 如果发现雷同-,雷同的作业即视为互相抄袭,无论是抄袭者还是被抄袭者,都将判为零分!。

oracle平时作业二

oracle平时作业二

平时作业二 Oracle的对象及其管理1.SQL操作根据ORACLE数据库SCOTT模式下的emp和dept表,完成下列操作:(1)查询20号部门的所有员工信息(2)查询所有工种为CLEAR员工的员工号、员工名和部门号。

(3)查询奖金(COMM)高于工资(SAL)的员工信息。

(4)查询资金高于工资20%的员工信息。

(5)统计每个部门各工种的人数与平均工资。

(6)查询所有员工中,工资排名在5-10的员工信息。

2.简述游标的作用和游标使用的基础步骤。

游标的作用是将数据库的中数据检索出来后缓存,可以被PL/SQL程序一行一行的读取并处理。

支持一条、多条、零条记录的处理。

游标的基本操作步骤为:(1)声明游标,使用查询来定义游标的列和行(2)打开游标,使用PL/SQL命令OPEN来打开一个声明的游标(3)提取数据,从游标中重复提取每条记录到数据结构中,直到数据集合被提交(4)关闭游标,使用完游标后将其关闭3.实训题根据ORACLE数据库SCOTT模式下的emp和dept表,完成下列操作:(1)编写一个PL/SQL块,输出所有员工的员工名,员工号,工资和部门号。

(2)创建一个存储过程,以员工号为参数,输出该员工的工资。

(3)创建一个存储过程,以员工号为参数,修改该员工的工资。

若该员工属于10号部门,则工资增加150;若属于20号部门,则工资增加200;若员工属于30号部门,则工资增加250.(4)创建一个函数,以员工号为参数,返回该员工的工资。

(5)在emp表中创建一个触发器,当删除emp表中的数据时,自动向与emp表结构相同的emp_copy表中插入相同的一条记录。

Oracle数据库-作业2-答案

Oracle数据库-作业2-答案

Oracle数据库-作业2-答案第二次书面作业答案(作业在2013.5.15之前交,使用学院统一的作业封面,题目可以打印,答题内容必须手写)一、填空题1.PL/SQL程序块主要包括3个主要部分:声明部分、执行部分和异常处理部分。

2.使用显式游标主要包括4个步骤:声明游标、打开游标、提取数据、关闭游标。

3.在PL/SQL中,如果SELECT语句没有返回任何记录,则会引发NO_DATA_FOUND 异常。

4.查看操作在数据表中所影响的行数,可通过游标的%ROWCOUNT 属性实现。

5.在下面程序的空白处填写适当的代码,使该函数可以获取指定编号的员工薪金。

CREATE OR REPLACE FUNCTION get_sal(P_ID varchar2) return number isv_sal number;beginselect sal into v_sal from emp where empno= P_ID ;returen v_sal;exceptionwhen no_data_found thendbms_output.put_line('无法找到该编号的员工!');when others thendDms_output.put_line('发生其他错误!');end get_sal;6.ROWID实际上保存的是记录的物理地址,因此通过ROWID 来访问记录可以获得最快的访问速度。

7.完成下面的语句,使其可以为EMPLOYEES表的EMPNO列添加一个名为PK_EMPNO的主键约束。

ALTER TABLE EMPLOYEES ADD CONSTRAINT PK_EMPNOPRIMARY KEY EMPNO ;8.B树索引可以是惟一的或者不惟一的,惟一的B树索引可以保证索引列上不会有重复的值。

9.Oracle数据库提供的对表或索引的分区方法有5种,分别为:范围分区、散列分区、列表分区、组合范围散列分区和组合范围列表分区。

oracle实验内容2(共40题)

oracle实验内容2(共40题)

Part 11.Write a query to display the current date. Label the column Date.select to_char(sysdate,'year-mon-day')“D ate”from dual2. The HR department needs a report to display the employee number, last name, salary, and salary increased by 15.5% (expressed as a whole number) for each employee. Label the column New Salary. Place your SQL statement in a text file named lab_03_02.sql.select employee_id,last_name,salary,salary*1.155 new_salaryfrom employees3. Run your query in the file lab_03_02.sql.4. Modify your query lab_03_02.sql to add a column that subtracts the old salary fromthe new salary. Label the column Increase. Save the contents of the file as lab_03_04.sql. Run the revised query.select employee_id,last_name,salary,salary*1.155new_salary,salary*0.155 increasefrom employees……5.Write a query that displays the last name (with the first letter uppercase and all other letterslowercase) and the length of the last name for all employees whose name starts with the letters J, A, or M. Give each column an appropriate label. Sort the results by the employees’ last names.select last_name,length(last_name) lengthfrom employeeswhere last_name like'A%'or last_name like'J%'or last_name like'M%' order by last_nameRewrite the query so that the user is prompted to enter a letter that starts the last name. For example, if the user enters H when prompted for a letter, then the output should show all employees whose last name starts with the letter H.6. The HR department wants to find the length of employment for each employee. For each employee, display the last name and calculate the number of months between today and the date on which the employee was hired. Label the column MONTHS_WORKED. Order your results by the number of months employed. Round the number of months up to the closest whole number.Note: Your results will differ.select last_name,round(months_between(sysdate,hire_date))"MONTHS_WORKED"from employeesorder by hire_date desc7. Create a report that produces the following for each employee:<employee last name> earns <salary> monthly but wants <3 times salary>. Label the column Dream Salaries.select last_name||' earns'||to_char(salary,'$999,999.99')||' monthly but wants'||to_char(3*salary,'$999,999.99')from employees8.Create a query to display the last name and salary for all employees. Format the salary to be15 characters long, left-padded with the $ symbol. Label the column SALARY.select last_name,lpad(salary,15,'$')"SALARY"from employees9.Display ea ch employee’s last name, hire date, and salary review date, which is the firstMonday after six months of service. Label the column REVIEW. Format the dates to appear in the format similar to “Monday, the Thirty-First of July, 2000.”Select last_name,to_char(hire_date,'dd-mm-yy')"hire_date",to_char(next_day(add_months(hire_date,’星期一'),'day,"the" ddspth "of" month,yyyy') "REVIEW"from employees10.Display the last name, hire date, and day of the week on which the employee started. Labelthe column DAY. Order the results by the day of the week, starting with Monday.select last_name,hire_date,to_char(hire_date,'day')"DAY"from employeesorder by to_char(hire_date-1,'d')11.Create a query that displays the employees’ last names and commission amounts. If anemployee does not earn commission, show “No Commission.” Label the column COMM. Select last_name,nvl(to_char(commission_pct),' No Commission')"COMM"From employees12.Create a query that displays the first eight characters of the employees’ last names andindicates the amounts of their salaries with asterisks. Each asterisk signifies a thousand dollars. Sort the data in descending order of salary. Label the column EMPLOYEES_AND_THEIR_SALARIES.Select rpad(substr(last_name,1,8),8)|| lpad(' ',salary/1000,'*')from employeesorder by salary desc13. Using the DECODE function, write a query that displays the grade of all employees based on the value of the column JOB_ID, using the following data:Job GradeAD_PRES AST_MAN BIT_PROG CSA_REP DST_CLERK ENone of the above 0select job_id,decode(job_id,'AD_PRES','A','ST_MAN','B','IT_PROG','C','SA_REP','D','ST_CLERK','E',0)"GRA"from employees14. Rewrite the statement in the preceding exercise using the CASE syntax.select job_id,case job_id when'AD_PRES'then'A'when'ST_MAN'then'B'when'IT_PROG'then'C'when'SA_REP'then'D'when'ST_CLERK'then'E'else'0'end"GRA"from employees15.Group functions work across many rows to produce one result per group.True/False T16.Group functions includee nulls in calculations.True/False F17.The WHERE clause restricts rows before inclusion in a group calculation.True/False TThe HR department needs the following reports:18.Find the highest, lowest, sum, and average salary of all employees. Label the columns Maximum, Minimum, Sum, and Average, respectively. Round your results to the nearest whole number. Place your SQL statement in a text file named lab_04_04.sql.select max(salary)"maximum",min(salary)"minimum",sum(salary) "Sum", round(avg(salary))"Average"from employees19,Modify the query in lab_04_04.sql to display the minimum, maximum, sum, and average salary for each job type. Resave lab_04_04.sql as lab_04_05.sql. Run the statement in lab_04_05.sql.select job_id,max(salary)"maximum",min(salary)"minimum",sum(salary)"Sum", round(avg(salary))"Average"from employeesgroup by job_id20.Write a query to display the number of people with the same job.select job_id,count(*)from employeesgroup by job_id21. Determine the number of managers without listing them. Label the column Number of Managers. Hint: Use the MANAGER_ID column to determine the number of managers.select count(distinct manager_id) "Number of Managers"from employees22.Find the difference between the highest and lowest salaries. Label the column DIFFERENCE. select max(salary)-min(salary)"Difference"from employees23.Create a report to display the manager number and the salary of the lowest-paid employeefor that manager. Exclude anyone whose manager is not known. Exclude any groups where the minimum salary is $6,000 or less. Sort the output in descending order of salary.select manager_id,min(salary)from employeeswhere manager_id is not nullgroup by manager_idhaving min(salary)>600024.Create a query to display the total number of employees and, of that total, the number of employees hired in 1995, 1996, 1997, and 1998. Create appropriate column headings.select count(*) total,sum(decode(to_char(hire_date,'yyyy'),'1995',1,0))"1995",sum(decode(to_char(hire_date,'yyyy'),'1996',1,0))"1996",sum(decode(to_char(hire_date,'yyyy'),'1997',1,0))"1997",sum(decode(to_char(hire_date,'yyyy'),'1998',1,0))"1998"from employees25. Create a matrix query to display the job, the salary for that job based on department number, and the total salary for that job, for departments 20, 50, 80, and 90, giving each column an appropriate heading.select job_id "JOB",sum(decode(department_id,20,salary,0))"Dept 20",sum(decode(department_id,50,salary,0))"Dept 50",sum(decode(department_id,80,salary,0))"Dept 80",sum(decode(department_id,90,salary,0))"Dept 90",sum(salary)"Total" from employeesgroup by job_id26.Write a query for the HR department to produce the addresses of all the departments. Use the LOCATIONS and COUNTRIES tables. Show the location ID, street address, city, state or province, and country in the output. Use a NATURAL JOIN to produce the results.select LOCATION_ID,STREET_ADDRESS,CITY,STATE_PROVINCE,COUNTRY_NAMEfrom LOCATIONS natural join COUNTRIES27.The HR department needs a report of all employees. Write a query to display the last name, department number, and department name for all employees.select last_name,department_id,department_namefrom employees natural join departments28.The HR department needs a report of employees in Toronto. Display the last name, job, department number, and department name for all employees who work in Toronto.select last_name,job_id,department_id,department_name,cityfrom employees join departments using(department_id)join locations using(location_id)where city='Toronto'29.Create a report to display employees’ last name and employee number along with theirmanager’s last name and manager number. Label the columns Em ployee, Emp#, Manager,and Mgr#, respectively. Place your SQL statement in a text file named lab_05_04.sql. Select st_name,e1.employee_id,st_name,e1.manager_idFrom employees e1 join employees e2 on e1.manager_id=e2.employee_id30.Modify lab_05_04.sql to display all employees including King, who has no manager. Orderthe results by the employee number. Place your SQL statement in a text file named lab_05_05.sql. Run the query in lab_05_05.sql.Select st_name,e1.employee_id,st_name,e1.manager_idFrom employees e1 left join employees e2 on e1.manager_id=e2.employee_idOrder by e1.employee_id31.Create a report for the HR department that displays employee last names, departmentnumbers, and all the employees who work in the same department as a given employee.Give each column an appropriate label. Save the script to a file named lab_05_06.sqlselect e1.department_id,st_name EMPLOYEE,st_name COLLEAGUE from employees e1 join employees e2 on e1.DEPARTMENT_ID =e2.DEPARTMENT_ID and ST_NAME<>ST_NAMEorder by e1.department_id32.The HR department needs a report on job grades and salaries. To familiarize yourself withthe JOB_GRADES table, first show the structure of the table. Then create a query that displays the name, job, department name, salary, and grade for all employees.select last_name,job_id,department_name,salary,GRADE_LEVELfrom employees join departments using(department_id)join JOB_GRADES on salary>LOWEST_SAL and salary<HIGHEST_SAL33.The HR department wants to determine the names of all employees who were hired afterDavies. Create a query to display the name and hire date of any employee hired after employee Davies.select last_name,hire_datefrom employeeswhere hire_date>(select hire_date from employees where last_name ='Davies')34.The HR department needs to find the names and hire dates for all employees who werehired before their managers, along with their managers’ names and hire dates. Save the script to a file named lab5_09.sql.select ST_NAME,e1.HIRE_DATE,st_name,e2.hire_datefrom employees e1 join employees e2 on e1.MANAGER_ID = e2.employee_idwhere e1.hire_date<e2.hire_date35.The HR department needs a query that prompts the user for an employee last name. Thequery then displays the last name and hire date of any employee in the same department as the employee whose name they supply (excluding that employee). For example, if the user enters Zlotkey, find all employees who work with Zlotkey (excluding Zlotkey).select last_name,hire_datefrom employeeswhere department_id =(select department_idfrom employeeswhere last_name='&name')and last_name!='&name'36 .Create a report that displays the employee number, last name, and salary of all employees who earn more than the average salary. Sort the results in order of ascending salary.select department_id,last_name,salaryfrom employeeswhere salary>(select avg(salary)from employees)order by salary37.Write a query that displays the employee number and last name of all employees who work in a department with any employee whose last name contains a u. Place your SQL statement in a text file named lab_06_03.sql. Run your query.select employee_id,last_namefrom employeeswhere department_id in(select department_idfrom employeeswhere last_name like'%u%')38.The HR department needs a report that displays the last name, department number, and job ID of all employees whose department location ID is 1700.select last_name,department_id,job_idfrom employees join departments using(department_id)join locations using(LOCATION_ID )where LOCATION_ID =1700order by department_idModify the query so that the user is prompted for a location ID. Save this to a file named lab_06_04.sql.39.Create a report for HR that displays the last name and salary of every employee who reportsto King.select last_name,salaryfrom employeeswhere manager_id =(select employee_idfrom employeeswhere last_name ='King')40. Create a report for HR that displays the department number, last name, and job ID for every employee in the Executive department.select department_id,last_name,job_idfrom employees join departments using(department_id)where department_name='Executive'If you have time, complete the following exercise:40.Modify the query in lab_06_03.sql to display the employee number, last name, and salary ofall employees who earn more than the average salary and who work in a department withany employee whose last name contains a u. Resave lab_06_03.sql as lab_06_07.sql. Run the statement in lab_06_07.sql.select employee_id,last_name,salaryfrom employeeswhere department_id in(select department_idfrom employeeswhere last_name like'%u%')and salary >(select avg(salary)from employees)。

Oracle第二次作业

Oracle第二次作业
成绩评定:
1、根据实验情况和实验报告质量作出写事性评价
2、评分
综合评分
折合成等级
指导教师签名:
时间:年月日
安徽师范大学
数计学院实验报告
专业名称软件工程
实验室2060203
实验课程大型数据库系统
实验名称Байду номын сангаас
姓名陈仙如
学号*********
同组人员无
实验日期2014.5.23
注:实验报告应包含(实验目的,实验原理,主要仪器设备和材料,实验过程和步骤,实验原始数据记录和处理,实验结果和分析,成绩评定)等七项内容。具体内容可根据专业特点和实验性质略作调整,页面不够可附页。

oracle数据库期末考试试题及答案

oracle数据库期末考试试题及答案

oracle数据库期末考试试题及答案一、单选题(每题2分,共20分)1. Oracle数据库中,用于创建数据库表的命令是:A. CREATE DATABASEB. CREATE TABLEC. CREATE INDEXD. CREATE VIEW答案:B2. 在Oracle数据库中,以下哪个选项不是数据类型?A. NUMBERB. CHARC. DATED. FILE答案:D3. Oracle数据库中,用于删除表的命令是:A. DROP TABLEB. DELETE TABLEC. REMOVE TABLED. REMOVE答案:A4. 在Oracle数据库中,以下哪个命令用于查询表中的数据?A. SELECTB. INSERTC. UPDATED. DELETE答案:A5. Oracle数据库中,以下哪个选项不是SQL语句的组成部分?A. SELECTB. FROMC. WHERED. PRINT答案:D6. 在Oracle数据库中,以下哪个选项不是事务控制命令?A. COMMITB. ROLLBACKC. SAVEPOINTD. PRINT答案:D7. Oracle数据库中,以下哪个选项不是索引类型?A. B-treeB. BitmapC. HashD. List答案:D8. 在Oracle数据库中,以下哪个选项不是表约束类型?A. PRIMARY KEYB. FOREIGN KEYC. UNIQUED. CHECK答案:D9. Oracle数据库中,以下哪个命令用于添加表列?A. ADD COLUMNB. ALTER TABLEC. CREATE COLUMND. MODIFY COLUMN答案:B10. 在Oracle数据库中,以下哪个选项不是PL/SQL的组成部分?A. DECLAREB. BEGINC. ENDD. PRINT答案:D二、多选题(每题3分,共15分)1. Oracle数据库中,以下哪些选项是数据类型?A. VARCHAR2B. TIMESTAMPC. BOOLEAND. BLOB答案:A, B, D2. 在Oracle数据库中,以下哪些命令用于数据操纵?A. SELECTB. INSERTC. UPDATED. DELETE答案:B, C, D3. Oracle数据库中,以下哪些选项是表约束类型?A. PRIMARY KEYB. FOREIGN KEYC. CHECKD. UNIQUE答案:A, B, C, D4. 在Oracle数据库中,以下哪些选项是事务控制命令?A. COMMITB. ROLLBACKC. SAVEPOINTD. PRINT答案:A, B, C5. Oracle数据库中,以下哪些选项是索引类型?A. B-treeB. BitmapC. HashD. List答案:A, B, C三、简答题(每题5分,共20分)1. 请简述Oracle数据库中事务的概念及其重要性。

数据库原理实验任务

数据库原理实验任务

数据库原理A实验任务说明实验平台操作系统:Windows 7或Windows 8或Windows XP。

数据库管理系统:Oracle11g或Oracle12c。

注:各位同学自备笔记本电脑,在自己的电脑上完成全部实验任务;在安排的时间到指定的实验室进行实验。

实验任务上机任务分为三大部分第一部分基本操作。

(要求菜单式方式,命令方式两种方式都会))第二部分基于服务器端数据库系统实例练习。

第三部分数据库连接。

上机安排:上机前自行完成实验1 Oracle11g或Oracle12c的安装和使用第一次:实验2 SQL数据定义、数据更新和数据查询第二次:实验3 SQL数据完整性控制实验4 SQL 数据安全性控制实验5 存储过程第三次:实验6 触发器实验7 数据导入导出第四次: 实验8 基于服务器端开发的职工管理系统(用PL/SQL编程实现,提交电子档作为上机作业。

)实验9 数据库连接第一部分基本操作实验1 Oracle11g或Oracle12c的安装和使用(上机前自行完成)实验目的:1. 通过安装某个数据库管理系统,初步了解Oracle11g或Oracle12c的运行环境。

2. 了解Oracle11g或Oracle12c交互界面、图形界面和系统管理工具的使用。

3. 搭建实验平台。

实验内容和要求:1. 根据某个Oracle版本的安装说明等文档,安装Oracle11g或Oracle12c。

2. 了解Oracle11g或Oracle12c的用户管理。

3. 熟悉交互界面的基本交互命令。

4. 熟悉图形界面的功能和操作。

5. 了解基本的Oracle11g或Oracle12c管理功能和操作。

6. 熟悉在线帮助系统的使用。

实验2 SQL数据定义和数据操纵等实验目的:1. 掌握关系数据库语言SQL的使用。

2. 使所有的SQL作业都能上机通过。

实验内容和要求:1. 建立数据库和表。

要求建立的数据库为SPJ数据库,S、P、J、SPJ个表,具体表中属性见教材第二章习题5。

Oracle综合测试二(含答案)

Oracle综合测试二(含答案)

综合测试二一、基础设置1.1 创建新用户test1密码test11.2 赋予test1管理员权限1.3 给予用户创建会话的权限1.4 给予用户创建表的权限1.5 修改当前会话的时间显示为以下格式“yyyy-mm-dd hh:mm:ss”二、数据管理操作某个学生运动会比赛信息的数据库,保存了如下的表:表1:运动会信息表gameinfo表2:运动员sporter成绩grade请用SQL语句完成如下功能:1. 在test1用户下建表,注意满足如下要求:a) 定义各个表的主码外码约束b) 运动员的姓名和所属系别不能为空值。

c) 积分要么为空值,要么为6,4,2,0, 分别代表第一,二,三名和其他名次的积分。

2. 往表中插入数据:运动会表(101,秋季运动会,工业大学,2008-8-8,1000,12300.50)运动员(1001, 李明,男,计算机系1002,张三,男,数学系1003, 李四,男,计算机系1004, 王二,男,物理系1005, 李娜,女,心理系1006, 孙丽,女,数学系)项目(x001, 男子五千米,一操场x002,男子标枪,一操场x003, 男子跳远,二操场x004, 女子跳高,二操场x005, 女子三千米,三操场)使用批量操作插入此表数据积分(1001, x001, 61002, x001, 41003, x001, 21004, x001, 01001, x003, 41002, x003, 61004, x003, 21005, x004, 61006, x004, 4)3. 完成如下操作1)查询运动会信息表以文字形式显示运动会的信息。

例如:工业大学秋季运动会在2008年8月8日举行,参加人数1000人,赛会预计费用12,300.50元。

2)由于客观原因,参赛人数减少20%,费用缩减为原来的90%,请更改运动会信息表。

3)1006号运动员的信息更改为孙梦,外语系。

4)计算参加运动会的男女运动员共多少人。

oracle数据库的试题及答案

oracle数据库的试题及答案

oracle数据库的试题及答案### Oracle数据库试题及答案#### 一、选择题1. 在Oracle数据库中,哪个命令用于创建数据库表?- A. CREATE TABLE- B. DROP TABLE- C. ALTER TABLE- D. TRUNCATE TABLE答案:A2. 以下哪个选项不是Oracle数据库的SQL语句?- A. SELECT- B. UPDATE- C. DELETE- D. PRINT答案:D3. Oracle数据库中,用于删除表中所有数据的命令是什么? - A. DELETE FROM table_name- B. TRUNCATE TABLE table_name- C. DROP TABLE table_name- D. CLEAR table_name答案:B4. 在Oracle数据库中,哪个命令用于查看表的结构?- A. DESCRIBE table_name- B. EXPLAIN table_name- C. DESC table_name- D. SHOW table_name答案:C5. Oracle数据库中,哪个命令用于插入数据?- A. INSERT INTO- B. ADD INTO- C. PUT INTO- D. SET INTO答案:A#### 二、简答题1. 简述Oracle数据库的体系结构。

- Oracle数据库的体系结构主要包括内存结构和存储结构。

内存结构包括系统全局区(SGA)和程序全局区(PGA)。

存储结构包括数据文件、控制文件和重做日志文件。

SGA是所有数据库进程共享的内存区域,包含了数据库缓冲区、重做日志缓冲区等。

PGA是每个服务器进程或后台进程的私有内存区域。

2. 什么是PL/SQL?它在Oracle数据库中的作用是什么?- PL/SQL是Oracle数据库的过程式扩展,它允许用户定义存储过程、函数、触发器等。

PL/SQL结合了SQL语句和过程式编程的特性,使得数据库编程更加灵活和强大。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

数据库oracle-第二次作业
题目1
完成
满分1.00
0qaid=22720781&0question 题干
3
以下哪个段可以进行自动管理?()
选择一项:
a. ROLLBACK
b. INDEX
c. CACHE
d. TEMPORARY
题目2
完成
满分1.00
0qaid=22720766&0question 题干
3
回滚段的作用有()。

选择一项:
a. 数据库恢复
b. 数据的读一致性
c. 事务回滚
d. 以上都是
题目3
完成
满分1.00
0qaid=22720780&0question 题干
3
以下哪个不属于Oracle的内存结构?()
选择一项:
a. 全局系统区
b. 用户区
c. 软件代码区
d. 排序区
题目4
完成
满分1.00
0qaid=22720771&0question 题干
3
如果没有指定临时表空间,以下哪个将作为临时表空间?()
选择一项:
a. INDEX
b. USERS
c. SYSTEM
d. TEMP
题目5
完成
满分1.00
0qaid=22720761&0question 题干
3
SGA是由以下哪些项组成的()。

选择一项:
a. Redo Log Buffer
b. Buffer Cache
c. Shared Pool
d. 以上都是
题目6
完成
满分1.00
0qaid=22720764&0question 题干
3
段的集合叫做()。

选择一项:
a. 区
b. 段
c. 数据库
d. 表空间
题目7
完成
满分1.00
0qaid=22720762&0question
题干
3
常见的后台进程LGWR的作用是()。

选择一项:
a. 日志写入程序
b. 归档
c. 进程监控
d. 数据库写入程序
题目8
完成
满分1.00
0qaid=22720779&0question 题干
3
以下哪个不是系统创建的表空间名称?()
选择一项:
a. 临时表空间
b. SYSAUX表空间
c. 用户表空间
d. SYSTEM表空间
题目9
完成
满分1.00
0qaid=22720772&0question 题干
3
数据库运行状态下,以下哪个表空间必须是联机状态?()
选择一项:
a. SYSTEM
b. TEMPORARY
c. USERS
d. ROLLBACK
题目10
完成
满分1.00
0qaid=22720784&0question 题干
3
直到以下哪个操作完成后,Oracle才认为事务已经提交?()
选择一项:
a. 事务所做的修改已由LGWR进程成功写入
Redo Log 文件
b. SMON进程提交了对数据所做的修改
c. 被修改的数据已由DBWR进程写入磁盘
d. PMON进程提交了对数据所做的修改
题目11
完成
满分1.00
0qaid=22720760&0question 题干
3
Oracle中管理用户会话连接的进程是()。

选择一项:
a. PMON
b. NET8
c. SMON
d. SERV
题目12
完成
满分1.00
0qaid=22720774&0question 题干
3
数据字典表和视图存储在()中。

选择一项:
a. 用户表空间
b. 临时表空间
c. 以上三者中的任何一个
d. 系统表空间
题目13
完成
满分1.00
0qaid=22720777&0question 题干
3
系统为了使性能最好和协调多个用户,在多进程
系统中使用一些附加进程,称为()。

选择一项:
a. 例程
b. 用户进程
c. 单进程
d. 后台进程
题目14
完成
满分1.00
0qaid=22720775&0question 题干
3
通过执行以下哪项命令来使example表空间处于在线备份模式?()
选择一项:
a. ALTER TABLESPACE example END
b. ALTER TABLESPACE example BEGIN BACKUP
c. ALTER TABLESPACE example END BACKUP
d. ALTER TABLESPACE example BEGIN
题目15
完成
满分1.00
0qaid=22720768&0question 题干
3
将被修改的数据块写入数据文件的进程是()。

选择一项:
a. DBWR
b. LGWR
c. PMON
d. SMON
题目16
完成
满分1.00
0qaid=22720776&0question 题干
3
完成诸如表空间合并等内部操作的进程是()。

选择一项:
a. DBWR
b. ARCH
c. SMON
d. PMON
题目17
完成
满分1.00
0qaid=22720770&0question 题干
3
如果发生实例故障,何时会用到回滚信息?()选择一项:
a. 实例恢复之后
b. 数据库重启后立即使用(在实例恢复之前)
c. 故障发生之前
d. 回滚信息不会用于故障和恢复过程中
题目18
完成
满分1.00
0qaid=22720763&0question 题干
3
初始化参数DB_BLOCK_SIZE的作用是()。

选择一项:
a. 标准数据块大小
b. 后台进程跟踪文件生成的位置
c. 非标准数据块数据缓冲区大小
d. 归档日志文件的默认文件存储格式
题目19
完成
满分1.00
0qaid=22720782&0question 题干
3
以下哪些是有效的Oracle后台服务器进程?()
选择一项:
a. LGWR
b. 以上都是
c. DBWR
d. ARCH
题目20
完成
满分1.00
0qaid=22720767&0question 题干
3
回滚段用于存储()。

选择一项:
a. 事务修改前的旧值
b. 以上都不对
c. 事务修改前后的旧值和新值
d. 事务修改后的新值
题目21
完成
满分1.00
0qaid=22720778&0question
题干
3
以下哪个不是Oracle的后台服务器进程?()选择一项:
a. DBCA
b. SMON
c. LGWR
d. DBWR
题目22
完成
满分1.00
0qaid=22720773&0question 题干
3
数据块的头部包括以下哪三部分信息?()
选择一项:
a. 标题、表目录和空闲空间
b. 表目录、行目录和标题
c. 标题、行数据和行头部
d. 表目录、行目录和行数据
题目23
完成
满分1.00
0qaid=22720769&0question 题干
3
排序操作需要用到以下哪个表空间?()
选择一项:
a. SYSTEM
b. TEMPORARY
c. USERS
d. ROLLBACK
题目24
完成
满分1.00
0qaid=22720783&0question 题干
3
用来存储最近被SQL语句访问过的数据块的区
域是()。

选择一项:
a. Shared Pool
b. PGA
c. UGA
d. Buffer Cache
题目25
完成
满分1.00
0qaid=22720765&0question 题干
3
回滚操作是()事务处理所做的工作。

选择一项:
a. 重复
b. 撤消
c. 备份
d. 删除。

相关文档
最新文档