最新Oracle11g数据库基础教程课后习题答案Word文档格式.docx

上传人:b****6 文档编号:21445949 上传时间:2023-01-30 格式:DOCX 页数:13 大小:20.22KB
下载 相关 举报
最新Oracle11g数据库基础教程课后习题答案Word文档格式.docx_第1页
第1页 / 共13页
最新Oracle11g数据库基础教程课后习题答案Word文档格式.docx_第2页
第2页 / 共13页
最新Oracle11g数据库基础教程课后习题答案Word文档格式.docx_第3页
第3页 / 共13页
最新Oracle11g数据库基础教程课后习题答案Word文档格式.docx_第4页
第4页 / 共13页
最新Oracle11g数据库基础教程课后习题答案Word文档格式.docx_第5页
第5页 / 共13页
点击查看更多>>
下载资源
资源描述

最新Oracle11g数据库基础教程课后习题答案Word文档格式.docx

《最新Oracle11g数据库基础教程课后习题答案Word文档格式.docx》由会员分享,可在线阅读,更多相关《最新Oracle11g数据库基础教程课后习题答案Word文档格式.docx(13页珍藏版)》请在冰豆网上搜索。

最新Oracle11g数据库基础教程课后习题答案Word文档格式.docx

\ORACLE\ORADATA\ORCL\userdata05.dbf’SIZE50M’;

(9)

ALTERTABLESPACEEXAMPLE

\ORACLE\ORADATA\ORCL\example05.dbf’SIZE20M’;

(10)

ALTERDATABASEDATAFILE‘D:

\ORACLE\ORADATA\ORCL\userdata05.dbf’AUTOEXTENDONNEXT5MMAXSIZE100M;

(14)

\ORACLE\ORADATA\ORCL\redo05a.log’,

’D:

\ORACLE\ORADATA\ORCL\redo05b.log’)SIZE5M;

(15)

ALTERDATABASEADDLOGFILEMEMBER

\ORACLE\ORADATA\ORCL\redo05c.log’TOGROUP5;

(16)

SHUTDOWNIMMEDIATE

STARTUPMOUNT

第6章数据库对象的创建与管理

2.实训题

(2)

Createtableexer_class(

CNOnumber

(2)primarykey,

CNAMEvarchar2(20),

NUMnumber(3)

Createtableexer_student(

SNOnumber(4)primarykey,

SNAMEvarchar2(10)unique,

SAGEnumber,

SEXchar

(2),

CNOnumber

(2)

(3)

Altertableexer_studentaddconstraintck_sagecheck(sage>

0andsage<

=100);

(4)

altertableexer_studentaddconstraintck_stucheck(sex='

M'

orsex='

F'

)modifysexdefault'

(5)

Createuniqueindexind_cnameonexer_class(cname);

(6)

Createviews_cas

Selectsno,sname,sage,sex,o,cname,num

Fromexer_classcjoinexer_students

Ono=o;

(7)

Createsequencesequ1startwith100000001;

createtableexer_student_range(

snonumber(4)primarykey,

snamevarchar2(10),sagenumber,

sexchar

(2),cnonumber

(2))

partitionbyrange(sage)

(partitionpart1valueslessthan(20)tablespaceexample,

partitionpart2valueslessthan(30)tablespaceorcltbs1,

partitionpart3valueslessthan(maxvalue)tablespaceorcltbs2)

createtableexer_student_list(

partitionbylist(sex)

(partitionmanvalues('

)tablespaceorcltbs1,

partitionwomanvalues('

)tablespaceorcltbs2)

(10)

Createindexindonexer_student_range(sno)local;

第9章PL/SQL语言基础

1.实训题

(1)

declare

cursorc_empisselect*fromemployees;

begin

forv_empinc_emploop

dbms_output.put_line(v_emp.first_name||'

'

||v_emp.last_name||'

||

v_emp.employee_id||'

||v_emp.salary||'

||v_emp.department_id);

endloop;

end;

v_avgsalemployees.salary%type;

forv_empin(select*fromemployees)loop

selectavg(salary)intov_avgsalfromemployees

wheredepartment_id=v_emp.department_id;

ifv_emp.salary>

v_avgsalthen

endif;

cursorc_empis

selecte.employee_ideid,e.last_nameename,

e.department_idedid,m.employee_idmid,m.last_namemname

fromemployeesejoinemployeesm

one.manager_id=m.employee_id;

v_empc_emp%rowtype;

openc_emp;

loop

fetchc_empintov_emp;

exitwhenc_emp%notfound;

dbms_output.put_line(v_emp.eid||'

||v_emp.ename||'

v_emp.edid||'

||v_emp.mid||'

||v_emp.mname);

closec_emp;

v_empemployees%rowtype;

select*intov_empfromemployeeswherelast_name='

Smith'

;

dbms_output.put_line(v_emp.employee_id||'

v_emp.first_name||'

v_emp.salary||'

exception

whenno_data_foundthen

insertintoemployees(employee_id,last_name,salary,email,hire_date,

job_id,department_id)

values(2010,'

7500,'

smith@'

to_date('

2000-10-5'

'

yyyy-mm-dd'

),'

AD_VP'

50);

whentoo_many_rowsthen

forv_empin(select*fromemployeeswherelast_name='

)loop

第10章PL/SQL程序设计

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

createorreplaceprocedurepro_showsal(

p_empnoemployees.employee_id%type)

as

v_salemployees.salary%type;

selectsalaryintov_salfromemployees

whereemployee_id=p_empno;

dbms_output.put_line(v_sal);

whenno_data_foundthen

dbms_output.put_line('

thereisnotsuchanemployees'

);

pro_showsal(100);

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

若该员工属于10号部门,则工资增加140元;

若属于20号部门,则工资增加200元;

若属于30号部门,则工资增加250元;

若属于其他部门,则工资增长300元。

createorreplaceprocedurepro_updatesal(

v_deptnoemployees.department_id%type;

v_incnumber;

selectdepartment_idintov_deptnofromemployees

casev_deptno

when10thenv_inc:

=140;

when20thenv_inc:

=200;

when30thenv_inc:

=250;

elsev_inc:

=300;

endcase;

updateemployeessetsalary=salary+v_inc

(5)创建一个包,包中包含一个函数和一个过程。

函数以部门号为参数,返回该部门员工的最高工资;

过程以部门号为参数,输出该部门中工资最高的员工名、员工号。

createorreplacepackagepkg_emp

functionfunc_ret_maxsal(p_deptnonumber)returnnumber;

procedurepro_showemp(p_deptnonumber);

 

createorreplacepackagebodypkg_emp

functionfunc_ret_maxsal(p_deptnonumber)

returnnumber

as

v_maxsalnumber;

begin

selectmax(salary)intov_maxsalfromemployees

wheredepartment_id=p_deptno;

returnv_maxsal;

end;

procedurepro_showemp(p_deptnonumber)

cursorc_empisselect*fromemployees

wheredepartment_id=p_deptnoand

salary=func_ret_maxsal(p_deptno);

v_emp.salary);

(6)创建一个包,包中包含一个过程和一个游标。

游标返回所有员工的信息;

存储过程实现每次输出游标中的5条记录。

createorreplacepackagepkg_showemp

procedureshow_fiveemp;

createorreplacepackagebodypkg_showemp

procedureshow_fiveemp

ifnotc_emp%isopenthen

foriin1..20loop

ifc_emp%notfoundthen

exit;

v_emp.first_name);

pkg_showemp.show_fiveemp;

(7)在employees表上创建一个触发器,保证每天8:

00~17:

00之外的时间禁止对该表进行DML操作。

createorreplacetriggertrg_emp

beforeinsertorupdateordeleteonemployees

ifto_char(sysdate,'

HH24:

MI'

)notbetween'

08:

00'

and'

17:

then

raise_application_error(-20000,'

此时间内,不允许修改EMPLOYEES表'

endif;

(8)在employees表上创建一个触发器,当插入、删除或修改员工信息时,统计各个部门的人数及平均工资,并输出。

createorreplacetriggertrg_8

afterinsertorupdateordelete

onemployees

cursorc_deptis

selectdepartment_id,avg(salary)avgsal,count(*)num

fromemployeesgroupbydepartment_id;

forvinc_deptloop

dbms_output.put_line(v.department_id||'

v.avgsal||'

||v.num);

第13章安全管理

CREATEUSERusera_exerIDENTIFIEDBYuseraDEFAULTTABLESPACEUSERSQUOTA10MONUSERSACCOUNTLOCK;

CREATEUSERuserb_exerIDENTIFIEDBYuserb;

GRANTCREATESESSIONTOusera_exerWITHADMINOPTION;

GRANTSELECT,UPDATEONehr.employeesTOusera_exerWITHGRANTOPTION;

ALTERUSERusera_exerACCOUNTUNLOCK;

CONNECTusera_erer/usera

SELECT*FROMehr.employees;

UPDATEehr.employeesSETsalary=salary+100;

GRANTSELECT,UPDATEONehr.employeesTOuserb_exer;

REVOKECREATESESSIONFROMusera_exer;

GRANTCREATESESSIONTOusera_exer;

REVOKESELECT,UPDATEONehr.employeesFROMusera_exer;

GRANTSELECT,UPDATEONehr.employeesTOusera_exer;

CREATEROLErolea;

CREATEROLEroleb;

GRANTCREATETABLETOrolea;

GRANTINSERT,UPDATEONehr.employeesTOrolea;

GRANTCONNECT,RESOURCETOroleb;

GRANTrolea,rolebTOusera_exer;

CREATEPROFILEpwdfile

LIMITCONNECT_TIME30IDLE_TIME10FAILED_LOGIN_ATTEMPTS4PASSWORD_LIFE_TIME20PASSWORD_LOCK_TIME10

ALTERUSERusera_exerPROFILEpwdfile;

第14章备份与恢复

(1)对human_resource数据库进行冷备份。

(2)对human_resource数据库进行一次完全的热备份。

(3)备份human_resource数据库的控制文件。

(4)假定human_resource数据库丢失了数据文件users01.dbf,使用数据库热备份对数据库进行恢复,并验证恢复是否成功。

(8)使用expdp命令导出human_resource数据库的ehr模式下的所有数据库对象。

第15章备份与恢复

(4)假设2013-3-12日在数据库中执行了下列操作。

略略略(课本可看)(P254)

(5)利用闪回查询,查询15:

40:

10时exercise中的数据

(6)利用闪回版本查询,查询15:

35:

10~15:

42:

10之间sno=100的记录版本信息

(7)利用闪回表技术,将exercise表恢复到删除操作进行之前的状态

(8)执行“DROPTABLEexercise”语句然后利用闪回删除技术恢复exercise表

(9)将数据库中的闪回日志保留时间设置为3天(4320分钟)

(10)利用闪回数据库技术,将数据库恢复到创造表之前的状态

settimeon

createtableflash_table(

idNUMBERPRIMARYKEY,

nameCHAR(20)

);

insertintoflash_tablevalues(100,'

jack'

commit;

insertintoflash_tablevalues(200,'

king'

insertintoflash_tablevalues(300,'

john'

select*fromflash_table;

selectcurrent_scnfromv$database;

updateflash_tablesetname='

wang'

whereid=100;

deletefromflash_tablewhereid=300;

altertableflash_tableENABLEROWMOVEMENT;

flashback

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

当前位置:首页 > 表格模板 > 合同协议

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1