oracle数据库大作业.docx

上传人:scccc 文档编号:12565473 上传时间:2021-12-04 格式:DOCX 页数:15 大小:30.14KB
返回 下载 相关 举报
oracle数据库大作业.docx_第1页
第1页 / 共15页
oracle数据库大作业.docx_第2页
第2页 / 共15页
oracle数据库大作业.docx_第3页
第3页 / 共15页
oracle数据库大作业.docx_第4页
第4页 / 共15页
oracle数据库大作业.docx_第5页
第5页 / 共15页
亲,该文档总共15页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述

《oracle数据库大作业.docx》由会员分享,可在线阅读,更多相关《oracle数据库大作业.docx(15页珍藏版)》请在三一文库上搜索。

1、2013-2014学年第二学期大型数据库技术考查报告课题名称:图书管理系统系统班级:11软工java2班学号:1115115020姓名:戴春奇成绩:2014年5月1 课题概述1.1 课题简介随着社会的发展,人们对知识的需求也不断的增长。在这种形式下,人们就要不断 的学习,不断的给自己充电, 而图书馆就自然而然地在人们的生活中占据了一定的位置, 如何科学的管理图书馆不但关系到读者求知的方便程度,也关系到图书馆的发展。图书 馆作为一种信息资源的集散地, 用户借阅资料繁多, 包含很多的信息数据的管理。 现今, 有很多的图书馆都是初步开始使用,有些甚至尚未使用计算机进行信息管理。数据信息 处理工作量大

2、,容易出错;用于数据繁多,容易丢失,且不易查找。总的来说,缺乏系 统,规范的信息管理手段。尽管有的图书馆有计算机,但是尚未用于信息管理,没有发 挥它的效力,资源闲置比较突出。因此一个好的图书馆管理系统是非常重要的。1.2 功能描述1登录模块用户登录:用户在登陆页面登陆,登陆成功进入系统。 管理员登陆:用于管理员的登陆,在后台登陆页面登陆,登陆成功进入 系统。 图书管理员与系统管理员后台功能不一样。 查询用户表, 对应用户名、 密码正确则进入系统,对应用户名密码不正确则显示相应信息。2图书管理模块对图书进行添加、查询、修改、删除、添加。将输入的图书信息添加到数据库图书表中,以方便进行各种查询及更

3、新 操作,根据输入的图书名称或作者,查询数据库图书表中的相应记录并显示 相应图书信息,更新数据库图书表中对应记录并显示更新后的图书信息,删 除数据库图书表中对应记录。3副本信息模块对图书的副本信息进行添加、修改、删除。 将输入的图书副本信息添加 到副本表中,并分配一个独立的中南码根据输入的中南码或国际标准图书编 码,查询图书副本表,显示副本信息更新副本表的数据库、删除副本表中所 对应的图书信息、修改副本表中错误的信息并更新数据库。4 用户管理模块对用户进行添加、删除、修改。 将输入的用户信息添加到用户表中,并 分配一个独立的用户号根据输入的用户名的姓名或生日,查询用户表,显示 用户信息更新用户

4、表的数据库、删除用户表中所对应的、修改用户中错误的 信息并更新数据库。2、数据库设计及实现2.1 数据库表清单1、图书信息Books表编号字段数据类型数据长度能否为空中文名备注1ISBNChar20否国际标准图书编码主码2TitleChar30是书名3Pub nameChar30是出版者名4AuthorChar30是作者名5Author noNumber30是作者号6ZNCodeNumber30是中南码2、畐寸本Copies表编号字段数据类型数据长度能否为空中文名备注1CopyNoNumber10否畐本编号主码2ISBNChar20是国际标准图书编码3、作者信息Authors表编号字段数据类型

5、数据长度能否为空中文名备注1AuthorNoNumber10否作者号主码2AuthorNa meChar20是作者名4、类另廿Categories表编号字段数据类型数据长度能否为空中文名备注1ZNCodeNumber20否中南码主码2CateNameChar20是目录名5、作家-Writers 表编号字段数据类型数据长度能否为空中文名备注1ISBNChar20否国际标准图书编码主码2AuthorNoNumber20否作者号主码6、出版社Publishers表编号字段数据类型数据长度能否为空中文名备注1Pub nameChar30否出版者名主码2AddressChar50是地址7、用户Users

6、表编号字段数据类型数据长度能否为空中文名备注1UsersNoNumber12否用户编号主码2UserNameChar20否用户名3UserPwdChar20否用户密码4Quan xiaNumber20否权限5BirthdayDate否用户生日6EmailChar30是用户的邮箱7TelChar20是用户的联系电话8AddressChar20是籍贯2.2创建表空间/创建数据表空间SQL> create tablespace MYTBS2 datafile 'e:oracleMYTBSMYTBS1.dbf size 500m;表空间已创建。SQL> alter tablespa

7、ce MYTBS add datafile 'f:oracleMYTBSMYTBS2.dbf size 500m;表空间已更改create tablespace WTBS2 datafile Je:crftcLeMYTBSriVTBSl .dhff size 5眦叭轰空间已创肄。altei* tahlnftpAcr MVTBS 胡日 dataFiln f F:.dhfJiPIRm;丰空间已更改SQL?2.3创建用户配置文件SQL> Create profile lock_time limit2 password_life_time 303 failedogin_attempts

8、54 password_lock_time 7;配置文件已创建SQL> Create prof ile lock_t ine Unit 3 jpaEsword_life_tine3 failed_logln_at't6 npt s 54 paa5word_lock_t ine 7:配置文件已创建SQL> 2.4创建用户及分配权限SQL> create user DCQ ide ntified by 1115115020 default tablespace MYTBS;用户已创建。SQL> grant conn ect,resource,create view

9、to DCQ;授权成功。SQL> commit;提交完成。SQL> connect DCQ/1115115020;已连接。GQL> c-rente; u-scsr DCQ idlcntificd lb蜀 1115115828 deFoiulit tablcpacs MVTBC; 用户己创建。tlQLJ grant connectjresaui*cefcreate uiew ita fiCQ1;授杈成功。SQL> CDimit ;賈交完成SQL>DCQZ1H5115020;己连接。SQL> ,2.5基本表实现2.5.1图书管理系统表的实现(1) 表的功能概述。

10、表的存储空间的分配为books表和users表分配1M,其他的表都分配 256k具体表的数据列、数据类型、主键、外键、是否为空都在数据库表清单中详细 描述.(2) 表的实现代码1、图书信息Books表SQL> run1 create table Books2 (isbn char(20) not null primary key,title char(30),pubname char(30),3 author char(30),author no nu mber(30),z ncode nu mber(30)4 tablespace MYTBS 5* storage(i ni tial

11、1M)表已创建。SQL> pun1 create table Books2 <isbn chai*<20i not nmll ppiriat* keij,tit le ebar<30)pubname chAF<30>,3 Autiop cliar<30,authomo nuinljeFOd,zncode number(30)4 tahletpace MVIBS5* stopaye<initial 1M>耒已创建。2、副本Copies表SQL> create table copies2 (cop yno nu mber(10) not

12、n ull primary key,3 isb n char(20)4 tablespace MYTBS5 storage(initial 256k);表已创建。盟QL、 create table copies2 (石opyriQ nurwh爭丁«10nvt null pr-inftr k&y.3 is bn cliar<20>>4 tablespace HVTBS5 E towage < in it ial £££<:表已创建3、作者信息Authors表SQL> create table Authors2 (

13、zn code nu mber(20 )not n ull primary key,cate name char(20)3 tablespace MYTBS4 storage(initial 256k);表已创建SQL> create tabic Authors2 <sncodt; number<20>not null piniary key,catenane chai*<20>>3 taJblespecE HVTBS4 st o rage < in it i-a 1 256k> ;表已创建。SQL> _4、类另廿Categories

14、表SQL> create table Categories2 (zn code nu mber(20 )not n ull primary key,3 cate name char(20)4 tablespace MYTBS5 storage(initial 256k);表已创建SQlj create le Gategfor-les2 (zncodc nun)r(20>not null primary hey,3 catenane4 tablespace MVTBS5 storage<in it ia1 2 5£k>;表已创惠5、作家-Writers 表SQL

15、> create table Writers2 (isbn char(20)not null,3 author no nu mber(20 )not n ull,4 con stra int pk_writers primary key(isb n,authorno)5 tablespace MYTBS6 storage(initial 256k);表已创建£QL> create tali 1* Of iters2 isbn cliaf<26)not nu.ll,3 authomo nunliepOBnDt nixLLr4 int pls_writers prir&

16、#187;*ry key<ibn,*wt>iQrn»>>5 tAlcpce MYTBS6 storage < in it ial 256k):耒已创建“6、出版社Publishers表SQL> create table Publishers2 (pub name char(30 )not null primary key,address char(50)3 tablespace MYTBS4 storage(initial 256k);表已创建。SQL> create table Publislicrs2 puhnanc cliarSOnot

17、 null prinary Ket/,address char503 tablespace MVTBS4 storage<initial 256k); 耒已创塞8QL>7、用户Users表SQL> create table Users2 (UserName char(20) not null,3 UserPwd char(20) not null,4 UserNo nu mber(12) primary key,5 Birth date not null,6 Quan xia n nu mber(20),7 Email char(30),8 TEL char(20),9 Ad

18、dress char(20)10 tablespace MYTBS11 storage( in itial 1M);表已创建Greats Cable liters2 CUserName char<2B? not null,3 UserPwd chav<20> not null>4 UsapNo number<12 pviuiarp kesi,5 date not nullr6 Qunxian numlbei*<2©>,? Enail chav<30>,a TEL char(295,牛 Address cliar<2G19 t

19、ablespace NVTBS11 s co rage < in it ia.1 1H> ;表已创建。SQL分配权限:grant select on books to reader;grant select on publishers to reader;grant select on authors to reader;grant select on copies to reader;grant select on writers to reader;grant select on categories to reader;2.6索引表的实现2.6图书管理系统表的实现索引的创建代

20、码(1) 在Books表中的书名创建索引SQL> create in dex Books_title_idx on Books(title)2 pctfree 203 tablespace MYTBS;索引已创建。SQL> create index Books_t itle_idx on BooksCtitle>2 pctFvee 209 tablespace MVTBS;索引已创建。(2) 为Users表的姓名创建索引SQL> create in dex Users_user name_idx on Users(user name)2 pctfree 203 tabl

21、espace MYTBS;索引已创建。K QL ci'&te iLndetx Usersusernaifrie_ idx nn User-s (u.sei'ndn&2 pctfiree 203 tabl&spGe MYIBS;索引已创建。(3) 为copies表copyNo列添加外键约束,一本书对应只能有一个人借出去, 不可能有同时有很多人借同一本书。SQL> alter table copies add con stra int fk_copy foreig n key(cop yno) references2 Users(UserNo);表已更

22、改。SQL> commit;提交完成。t$bl& oopies addt fk.copy FopeignrttfeFences2 Users(UserNo>;表已更改SQL> comnlt;提交完成>QnT>2.7分区表的实现创建一个 Books 副本 books2 表,并为其创建分区, 使用 Hash 列分区(分区列 authorno), 要求创建的两个分区由系统自动生成分区名,并放置在表空间 MYTBS1 和 MyTBS2 中实现代码:SQL> create table books22 as select * from Books3 Partit

23、ion by hash(a uthorno)4 Partitions 25 Store in (MYTBS1, MYTBS2);3. 功能实现3.1 系统登录(1) 功能简介 用户登录验证, 可以创建一个存储过程, 输入参数是用户帐号、用户密码, 输出参数是整型值。 -1 表示登录失败, 0 表示没有此用户, 1 表示登录成功。(2) 实现代码set serveroutput on;create or replace procedure check_users( v_name in users. UserName%type, v_pwd users.UserPwd%type, flag out

24、 number)IScounts number;pcounts number;BEGINselect count(*) into counts from users where UserName=v_name;IF counts>0 THENselect count(*) into pcounts from users where UserPwd=v_pwd;IF pcounts>0 THENflag:=1;dbms_output.put_line(' 登录成功 !');END IF;ELSEflag:=0;dbms_output.put_line(' 没有

25、此用户 !');END IF;exceptionwhen no_data_found thenflag:=-1;dbms_output.put_line(' 登录失败 !');END CHECK_USERS;调用用户登录验证SET serveroutput ON;DECLAREV_NAME VARCHAR2(25);V_PASSWORD V ARCHAR2(25);V_RETURN NUMBER(5);BEGINV_NAME := 'admin'V_PASSWORD:= 'admin'CHECK_USERS(v_name=>V_NA

26、ME,v_pwd=>V_PASSWORD,flag=>V_RETURN);DBMS_OUTPUT.PUT_LINE('V_NAME = ' | V_NAME);DBMS_OUTPUT.PUT_LINE('V_PASSWORD = ' | V_PASSWORD);END;3.2 用户注册(1) 功能简介 本功能为管理员注册,使用过程 insert_ Users 实现。(2) 代码实现create or replace procedure insert_ Users (v_Id in Users.UserNo%type, v_pwd in Users.u

27、serpwd%type,v_ name in Users.username %typev_ Address in Users.Address %type v_ TEL in Users.TEL %type)is begininsert into Users values(v_id, v_pwd, v_ name,v_ Address,v_ TEL); dbms_output.put_line(' 注册成功! ');end insert_Users;(3)运行结果 调用过程: set serveroutput on;exec insert_Users ('01',

28、 1115115020, 'daichunqi',' 云南 ', 123456);3.3 用户修改信息(1)功能简介 本功能为用户修改信息,使用过程 update_ Users 实现。(2)代码实现create or replace procedure update_ Users ( v_Id in Users.UserNo%type, v_pwd in Users.userpwd%type, v_ name in Users.username %type v_ Address in Users.Address %type v_ TEL in Users.TEL %type)is beginAddress,TEL=v_update Users set userpwd=v_pwd, username=v_name,Address=v_ TEL where UserNO= v_Id);dbms_output.put_line(' 修改成功! ');end update_Users;(3)运行结果 调用过程:set serveroutput on;exec update_Users ('01', 1115115020, 'daichunqi',' 云南 ', 123456);

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

当前位置:首页 > 社会民生


经营许可证编号:宁ICP备18001539号-1