Oracle数据库应用与开发教材课后习题参考答案Word格式.docx

上传人:b****2 文档编号:800003 上传时间:2023-04-29 格式:DOCX 页数:15 大小:20.53KB
下载 相关 举报
Oracle数据库应用与开发教材课后习题参考答案Word格式.docx_第1页
第1页 / 共15页
Oracle数据库应用与开发教材课后习题参考答案Word格式.docx_第2页
第2页 / 共15页
Oracle数据库应用与开发教材课后习题参考答案Word格式.docx_第3页
第3页 / 共15页
Oracle数据库应用与开发教材课后习题参考答案Word格式.docx_第4页
第4页 / 共15页
Oracle数据库应用与开发教材课后习题参考答案Word格式.docx_第5页
第5页 / 共15页
Oracle数据库应用与开发教材课后习题参考答案Word格式.docx_第6页
第6页 / 共15页
Oracle数据库应用与开发教材课后习题参考答案Word格式.docx_第7页
第7页 / 共15页
Oracle数据库应用与开发教材课后习题参考答案Word格式.docx_第8页
第8页 / 共15页
Oracle数据库应用与开发教材课后习题参考答案Word格式.docx_第9页
第9页 / 共15页
Oracle数据库应用与开发教材课后习题参考答案Word格式.docx_第10页
第10页 / 共15页
Oracle数据库应用与开发教材课后习题参考答案Word格式.docx_第11页
第11页 / 共15页
Oracle数据库应用与开发教材课后习题参考答案Word格式.docx_第12页
第12页 / 共15页
Oracle数据库应用与开发教材课后习题参考答案Word格式.docx_第13页
第13页 / 共15页
Oracle数据库应用与开发教材课后习题参考答案Word格式.docx_第14页
第14页 / 共15页
Oracle数据库应用与开发教材课后习题参考答案Word格式.docx_第15页
第15页 / 共15页
亲,该文档总共15页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

Oracle数据库应用与开发教材课后习题参考答案Word格式.docx

《Oracle数据库应用与开发教材课后习题参考答案Word格式.docx》由会员分享,可在线阅读,更多相关《Oracle数据库应用与开发教材课后习题参考答案Word格式.docx(15页珍藏版)》请在冰点文库上搜索。

Oracle数据库应用与开发教材课后习题参考答案Word格式.docx

(5)SYSMAN:

该用户是企业管理的超级管理员账号,该账号能够创建和修改其他管理员账号,同时也能管理数据库实例。

(6)DBSNMP:

是Oracle数据库中用于智能代理(IntelligentAgent)的用户,用来监控和管理数据库相关性能。

如果停止该用户,则无法提取相关的数据库信息。

(7)方法一:

点击“开始”—>

“程序”—>

“Oracle-<

Oracle主目录名称>

”—>

“ApplicationDevelopment”—>

“SQLPlus”进入Windows环境下的图形窗口

(8)方法二:

“运行”—>

输入“cmd命令”—>

进入DOS环境下执行SQLPLUS命令也可以打开SQL*Plus工具。

(9)方式三:

在IE浏览器地址栏中输入

2.6习题

一、填空题

1.数据、日志、控制、初始化参数数据控制初始化参数

2.表空间、段、盘区、数据块盘区数据块

3.数据段盘区

4.用户进程服务进程后台进程用户进程服务进程

5.数据重做日志

6.修改过的数据数据文件

7.重做日志缓冲区内的日志重做日志

8.日志条目归档日志设备归档

9.共享服务器专有服务器共享服务器共享服务器

二、简答题

1.Oracle数据库的物理存储结构式从物理组成的角度分析一个数据库在存储介质上的实际构成,它是由操作系统组织和管理的,是Oracle数据库的外部存储结构。

(1)数据文件:

数据文件时Oracle数据库用来存储各种数据的地方,如表中的记录、索引数据、系统数据和临时数据等。

(2)日志文件:

在Oracle中,日志文件记录了用户对数据的修改信息(如增加、删除、修改),名字通常为READ*.LOG格式。

(3)控制文件:

控制文件时Oracle数据库的物理文件之一,它是一个很小的二进制文件,记录了数据库的名称、数据文件和连击日志文件的名称及位置、当前的日志序列号、表空间等信息。

(4)参数文件:

参数文件中记录着数据库名称、控制文件的路径、SGA的内存结构、可选的Oracle特性和后台进程的配置参数等信息。

(1)Oracle数据库逻辑存储结构是Oracle数据库创建后利用逻辑概念来描述数据库内部数据的组织和管理形式。

包括表空间、段、区和块四种。

(2)表空间和数据文件的关系:

数据库中的一个表空间至少包含一个或多个数据文件,而一个数据文件只能属于一个表空间。

这种关联实现了数据库的逻辑存储结构和物理存储结构的统一。

(1)数据库实例是用户访问数据库的中间层,是使用数据库的手段,它为用户访问数据库提供了必要的内存空间和多个Oracle进程,它是动态的、临时的。

一个Oracle实例由内存空间和Oracle进程两部分组成。

(2)数据库和数据库实例是相辅相成、缺一不可的。

如果只有数据库的物理文件,只能说明有数据被存储在数据库中,但是无法直接访问。

如果只有数据库实例,说明为数据库的使用做好了准备、可以访问数据库,但不知道要操作的数据在哪里。

(1)客户端配置

a)sqlnet.ora文件用于指定数据库连接账号的验证方式以及连接字符串的解析方式,也就是说通过该文件决定怎样查找一个连接中出现的连接字符串的定义。

b)tnsnames.ora文件时Oracle客户端的另一个重要文件,用来定义客户端连接远程服务器时的主机字符串。

(2)服务器端配置

一、listener.ora文件作用于Oracle数据库服务器端,是Oracle监听服务的配置文件。

当客户端向服务器提交连接请求时,由监听服务接受并对连接账号进行有效验证,验证通过后将用户进程交给服务进程处理。

若该文件被破坏,将影响监听服务的正常使用。

3.5习题

一、选择题

1.C2.C3.B

1.一个方案只能被一个数据库用户拥有,并且方案名称与这个用户的名称相同。

创建新用户时系统自动创建该用户的方案。

数据库的每一个用户都拥有一个唯一的方案。

该用户创建的方案对象默认被保存在自己的方案中。

2.CREATEUSER创建新用户命令:

(1)USER-NAME:

新创建的用户名称。

(2)PASSWORD:

为新用户制定密码。

(3)DEFAULTTABLESPACE:

为新用户指定默认表空间。

用来储存该用户创建的方案对象。

(4)TEMPORARYTABLESPACE:

为用户指定临时表空间,存储操作过程中产生的临时数据。

(5)QUOAT:

为新用户指定磁盘配额,表示该用户在指定的空间中可以占用的最大磁盘空间。

(6)UNLIMITED:

表示该用户可以使用无限大的空间。

(7)PROFILE:

指定新用户使用的配置文件。

(8)PASSWORDexpire:

表示新用户密码过期,登陆后需要给出新密码。

(9)ACCOUNTlock/unlock:

表示用户加锁/解锁状态。

其中,用户名和密码是必须有的。

三、操作题

1.CREATEUSERORA_TEMP

IDENTIFIEDBYTEM;

2.ALTERUSERORA_TEMP

IDENTIFIEDBYORA;

3.ALTERUSERORA_TEMP

ACCOUNTLOCK;

4.5实验

a)createtablestudent(

snochar(10)primarykey,

snamevarchar2(8),

sexchar

(2)default'

男'

check(sex='

男'

orsex='

女'

),

birthdaydate,

sdeptchar(20)

);

b)createtablecourse(

cnochar(10)primarykey,

cnamechar(30)unique,

ccreditnumber(3)

c)createtablescore(

snochar(10)referencesstudent(sno),

cnochar(10)referencescourse(cno),

gradenumber(3)check(grade>

=0andgrade<

=100),primarykey(sno,cno)

d)altertablestudent

add(memovarchar2(200));

e)altertablestudent

modify(memovarchar2(300));

f)altertablestudent

dropcolumnmemo;

insertintostudentvalues('

001'

'

zhang'

01-7月-1992'

生活部'

lisi'

11-5月-1992'

艺术部'

002'

wang'

default,'

21-8月-1992'

外联部'

insertintocoursevalues('

1001'

文学'

88'

1002'

99'

经济'

89'

.

insertintoscorevalues('

6'

7'

8'

g)updatescoresetsno='

003'

wheregrade='

;

updatescoresetcno='

1003'

wheresno='

h)deletefromstudentwheresname='

i)管理---方案---表---在“方案”和“对象名”文本框中输入要删除的方案名或表名,选择需要删除的表,单机“删除”。

j)droptablestudent;

4.6习题

1.AB2.B3C4.A5.B

6.C7A8C9.B10.A

5.5实验

(1)select*fromscott.empwheredeptno=20;

(2)selectempno,ename,deptnofromscott.empwherejob='

CLERK'

(3)select*fromscott.empwherecomm>

sal;

(4)select*fromscott.empwherecomm>

sal*0.2;

(5)select*fromscott.empwhere(deptno=10andjob='

MANAGER'

)or(deptno=20andjob='

(6)select*fromscott.empwherejobnotin('

)andsal>

=2000;

(7)select*fromscott.empwherecommisnotnull;

(8)selectcount(empno),avg(sal)fromscott.emp;

(9)select*fromscott.empwherecommisnullorcomm<

100

(10)select*fromscott.empwhere(sysdate-hiredate)/365<

=2;

(11)select*fromscott.empwhere(sysdate-hiredate)/365>

=10;

(12)selectinitcap(lower(ename))fromscott.emp;

(13)select*fromscott.empwherelength(ename)=6;

(14)select*fromscott.empwhereenamenotlike'

%S%'

(15)select*fromscott.empwhereenamelike'

_M%'

(16)selectsubstr(ename,1,3)fromscott.emp;

(17)selectreplace(ename,'

s'

S'

)fromscott.emp;

(18)selectename,hiredatefromscott.emporderbyhiredate;

(19)selectename,job,salfromscott.emporderbyjobdesc,salasc;

(20)selectename,extract(yearfromhiredate)as年份,extract(monthfromhiredate)as月份fromscott.emporderby月份,年份;

(21)selectdeptno,count(*),avg(sal),avg((sysdate-hiredate)/365)fromscott.empgroupbydeptno;

(22)selectcount(*),avg(sal)fromscott.empgroupbydeptno;

(23)selectmin(sal),jobfromscott.empgroupbyjobhavingmin(sal)<

3000;

(24)selectdeptno,job,max(sal)fromscott.empgroupbydeptno,job;

(25)selectcount(*),avg(sal)fromscott.empgroupbyjob;

5.6习题

1.C2.A3.A4.A5.C6.A7.B8.C9.A10.B

6.5习题

(1)

selectename,dnamefromscott.empt1innerjoinscott.deptt2ont1.deptno=t2.deptnowherejob='

(2)

select*fromscott.empt1rightjoinscott.deptt2ont1.deptno=t2.deptno

(3)

select*fromscott.empt1leftjoinscott.deptt2ont1.deptno=t2.deptno

(4)

用子查询实现:

select*fromscott.empwheredeptno=(selectdeptnofromscott.deptwheredname='

SALES'

用连接查询实现:

select*fromscott.empt1innerjoinscott.deptt2ont1.deptno=t2.deptnowheret2.dname='

注意两种实现方式,在行和列上的变化。

(5)简单自连接

selectt1.enameas员工姓名,t2.ename经理姓名fromscott.empt1,scott.empt2wheret1.mgr=t2.empno;

(6)

selectt1.enameas员工姓名,t2.ename经理姓名fromscott.empt1,scott.empt2wheret1.mgr=t2.empnoandt1.hiredate<

t2.hiredate

(7)

selectt1.ename,t1.job,t1.deptno,t2.ename,t2.job,t2.deptnofromscott.empt1crossjoinscott.empt2wheret1.job=t2.jobandt1.deptno<

>

t2.deptno

(8)

selectt1.enameas员工姓名,t2.ename经理姓名fromscott.empt1,scott.empt2wheret1.mgr=t2.empnoandt1.deptno=10;

(9)

select*fromscott.empwheresal>

2500

union

select*fromscott.empwherejob='

ANALYST'

(10)

intersect

(11)

2500

minus

(12)

(selectavg(sal)fromscott.emp)

(13)

select*fromscott.empwherejob=(selectjobfromscott.empwhereename='

SMITH'

(14)

(selectsalfromscott.empwhereename='

(15)

selectename,salfromscott.empwheresal>

all(selectsalfromscott.empwheredeptno=30)

(16)

select*fromscott.empwheredeptnoin(selectdeptnofromscott.empgroupbydeptnohavingcount(*)>

5);

(17)

select*fromscott.deptwheredeptnoin(selectdeptnofromscott.empgroupbydeptnohavingmin(sal)>

2000)

(18)本题的关键是使用子查询作为数据源和查询的条件,可以从最里层的子查询开始理解

select*fromscott.deptwheredeptnoin(selectdeptnofrom(selectdeptno,count(*)as人数fromscott.empgroupbydeptno)where人数=(selectmax(人数)from(selectdeptno,count(*)as人数fromscott.empgroupbydeptno)));

(19)

select*fromscott.deptwheredeptnoin(selectdeptnofromscott.empgroupbydeptnohavingcount(*)>

=1)

(20)本题关键是使用相关子查询做条件

select*fromscott.empewheresal>

(selectavg(sal)fromscott.empgroupbydeptnohavinge.deptno=deptno);

(21)本题关键是使用两个子查询的结果进行内连接查询

select*from((select*fromscott.empewheresal>

(selectavg(sal)fromscott.empgroupbydeptnohavinge.deptno=deptno))t1innerjoin

(selectavg(sal),deptnofromscott.empgroupbydeptno)t2ont1.deptno=t2.deptno);

(22)

select*fromscott.deptwheredeptnoin(selectdistinctdeptnofromscott.empwhereempnoin(selectdistinctmgrfromscott.emp));

(23)

select*fromscott.empt1,scott.deptt2wheret1.deptno=t2.deptnoandt1.deptnoin(selectdeptnofromscott.empgroupbydeptnohavingavg(sal)<

7.10习题

一、

1.执行部分

2.RAISE

二、

1.D2.B3.CE4.A5.B

1.

loop循环实现:

declare

inumberdefault1;

snumberdefault0;

begin

loop

s:

=s+i;

i:

=i+1;

exitwheni>

100;

endloop;

dbms_output.put_line('

和是:

'

||s);

end;

whlie循环实现:

whilei<

=100loop

for循环实现:

foriin1..100loop

2.

显示游标的for循环:

cursorcur1isselectename,salfromscott.emp;

forrecincur1loop

dbms_output.put_line(rec.ename||'

||rec.sal);

隐式游标的for循环:

forrecin(selectename,salfromscott.emp)loop

end

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > IT计算机 > 电脑基础知识

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2