Oracle2014课程设计题with answer 联系客服

发布时间 : 星期五 文章Oracle2014课程设计题with answer更新完毕开始阅读8974c83db84ae45c3b358cb0

2005186002 2006216117 2006216018 2010211110 2012123001 ReaderType表

李晓平 王海霞 程鹏 杨倩 张芳 RT_ID 1 2 3 2 1 3 3 2 RT_Name 教师 职工 学生 学生处 工程技术学院 信息工程学院 工程技术学院 后勤处 LimitNum 20 10 5 LendDate 2005-8-30 2008-9-1 2008-9-1 2014-3-5 2014-4-11 2014-4-12 Publish表 PubName 15103762156 13343811220 13703760258 15223468978 13700860288 LimitDays 120 90 60 ReturnDate 2005-9-26 2009-12-1 PubTel 010-77564582 010-25587788 010-88556616 010-78777444 010-63560056 010-59646999 010-59646999 男 女 男 女 女 Borrow表 R_ID 2004186001 2004186001 2006216117 2010211110 2010211110 2012123001 B_ID B00000001 B00000003 B00000006 B00000004 B00000005 B00000005 P_ID P001 P002 P003 P004 P005 P006 P007 BorrowInfo 否 否 是 高等教育出版社 人民邮电出版社 清华大学出版社 北京大学出版社 中国铁道出版社 北京交通大学出版社 北京交大出版社 insert into booktype values('01,'计算机类',NULL); insert into booktype values('02','通信类',NULL); insert into booktype values('03','经管类',NULL); insert into booktype values('04','数字艺术类',NULL); insert into booktype values('05','电气自动化类',NULL);

insert into readertype values('1','教师',20,120); insert into readertype values('2','职工',10,90); insert into readertype values('3','学生',5,60);

insert into borrow(R_ID,B_ID,LendDate,ReturnDate,BorrowInfo) values('2004186001','B00000001','2005-8-30','2005-9-26','否'); insert into borrow(R_ID,B_ID,LendDate,ReturnDate,BorrowInfo) values('2004186001','B00000003','2008-9-1','2009-12-1','否'); insert into borrow(R_ID,B_ID,LendDate,BorrowInfo) values('2006216117','B00000006','2008-9-1','是');

insert into borrow(R_ID,B_ID,LendDate) values('2010211110','B00000004','2014-3-5'); insert into borrow(R_ID,B_ID,LendDate) values('2010211110','B00000005','2014-4-11');

insert into borrow(R_ID,B_ID,LendDate) values('2012123001','B00000005','2014-3-12');

insert into publish values('P001','高等教育出版社','010-77564582'); insert into publish values('P002','人民邮电出版社','010-25587788'); insert into publish values('P003','清华大学出版社','010-88556616'); insert into publish values('P004','北京大学出版社','010-78777444'); insert into publish values('P005','中国铁道出版社','010-63560056'); insert into publish values('P006','北京交通大学出版社','010-59646999'); insert into publish values('P007','北京交大出版社','010-59646999');

insert into reader values('2004186001','张丽丽','1','信息工程学院','13526569236','女'); insert into reader values('2005186002','李晓平','2','学生处','15103762156','男');

insert into reader values('2006216117','王海霞','1','工程技术学院','13343811220','女'); insert into reader values('2006216018','程鹏','3','信息工程学院','13703760258','男'); insert into reader values('2010211110','杨倩','3','工程技术学院','15223468978','女'); insert into reader values('2012123001','张芳','2','后勤处','13700860288','女');

ALTER session SET nls_date_format = \

insert into book values('B00000001','数据库系统概论','萨师煊','01', 'P001','2006-5-1', 39.00,'9787040195835');

insert into book values('B00000002','数据结构','宗大华','01','P001','2008-4-1',28.00,'9787115169839');

insert into book values('B00000003','SQL SERVER应用技术','韦鹏程','01','P005','2011-5-1',26.00,'9787113124830');

insert into book values('B00000004','系统工程(修订版)','吕永波','01','P006','2006-1-1',29.00,'9787810821186');

insert into book values('B00000005','财经应用文写作教程','甘佩钦','03','P002','2012-3-1',33.00,'9787115270207');

insert into book values('B00000006','平面构成设计教程','姜巧玲','04','P002','2011-9-1',29.00,'9787115261052');

col b_name format a20 col author format a8 col price format 99.99 set pagesize 100

【任务5】更新表中数据

1.使用SQL语言将Book表中图书编号为B000000002的出版社编号修改为“P002”. update book set p_id='P002' where b_id='B00000002'

2.使用SQL语言把Reader表中的张芳的部门修改为“保卫处”。 update reader set rdept='保卫处' where r_name='张芳'

3.使用SQL语言删除Publish表中“北京交大出版社”的记录。 delete from publish where pubname='北京交大出版社'

【任务6】简单查询及连接查询

1.查询所有图书的基本信息。 select * from book

2.查询所有的图书编号、图书名称和价格。 select b_id,b_name,price from book

3.查询教师一次可以借书数量以及借书天数,输出的结果字段名分别用借书本数和借书期限表示。

select limitnum as 借书本数,limitdays as 借书期限 from readertype where rt_name='教师' 4.查询姓“张”读者的基本信息。

select * from reader where r_name like '张%' 5.查询Borrow表中未还图书的记录。

select * from borrow where returndate is null 6.查询2014年的借阅记录。

select * from borrow where to_char(lenddate,'yyyy')=2014

7.统计图书信息表中不同出版社出版的图书数目,把统计结果大于或等于2的结果输出。 select p_id,count(*) as pubnum from book group by p_id having count(*)>=2

select p_id,count(p_id) as pubnum from book group by p_id having count(p_id)>=2 8.查询Borrow表中所有借书的读者的借书证号、姓名以及所借图书的图书证号。 select borrow.r_id,r_name,b_id from borrow,reader where borrow.r_id=reader.r_id

9.查询Borrow表中所有借书的读者的借书证号、姓名以及所借图书的图书的详细信息。 select reader.r_id,r_name,book.* from borrow,reader,book where borrow.r_id=reader.r_id and book.b_id=borrow.b_id

10.查询借阅了书籍的读者和没有借阅的读者,显示他们的读者号、姓名、书名、借阅日期。 select reader.r_id,r_name,book.b_name,lenddate from book,reader,borrow where reader.r_id=borrow.r_id(+) and book.b_id(+)=borrow.b_id

select b_name,price ,pubname from book,publish where book.p_id=publish.p_id and

pubname in ('人民邮电出版社','高等教育出版社')

11.查询“人民邮电出版社”的图书中单价比“高等教育出版社”最高单价还高的图书名、单价。

select b_name,price from book,publish where book.p_id=publish.p_id and

pubname='人民邮电出版社' and price>all(select price from book,publish where book.p_id=publish.p_id and pubname='高等教育出版社') 12.查询从未被借阅过的图书信息。

select * from book where b_id not in (select b_id from borrow) /

select b_name from book,borrow where book.b_id=borrow.b_id select p_id,count(*) as pubnum from book group by p_id

13.查询每一个出版社出版的书籍的数量。

select pubname,count(*) as pubnum from book,publish where book.p_id=publish.p_id group by pubname

14.查询与《SQL SERVER应用技术》同一类型的所有图书的名称、作者、ISBN号。

select b_name,author,isbn from book where bt_id=(select bt_id from book where b_name='SQL SERVER应用技术')

15.查询所有单价小于平均单价的图书号、书名、出版社。

16.查询与《SQL SERVER应用技术》同一出版社的所有图书的图书名称、作者、ISBN号。 17.查询姓名为“杨倩”的读者的借阅记录。

select r_name,borrow.* from reader,borrow where borrow.r_id=reader.r_id and r_name='杨倩' 18.查询姓名为“杨倩”的读者的所借图书的详细信息。 select book.* from reader,borrow,book where borrow.r_id=reader.r_id and book.b_id=borrow.b_id and r_name='杨倩'

19.查询借阅了“高等教育出版社”出版的书名中包含有“数据库”3个字的图书,或者借阅了“中国铁道出版社”出版的书名中含有“SQL”3个字的图书的读者姓名、书名。

select r_name,b_name from book,borrow,publish,reader where reader.r_id=borrow.r_id and book.b_id=borrow.b_id and book.p_id=publish.p_id and

pubname='高等教育出版社' and b_name like '%数据库%' union

select r_name,b_name from book,borrow,publish,reader where reader.r_id=borrow.r_id and book.b_id=borrow.b_id and book.p_id=publish.p_id and

pubname='中国铁道出版社' and b_name like '%SQL%'

20.查询借阅了“高等教育出版社”出版的书名中包含有“数据库”3个字的图书,并且也借阅了“中国铁道出版社”出版的书名中含有“SQL”3个字的图书的读者姓名。 select r_name from book,borrow,publish,reader where reader.r_id=borrow.r_id and book.b_id=borrow.b_id and book.p_id=publish.p_id and pubname='高等教育出版社' and b_name like '%数据库%' intersect

select r_name from book,borrow,publish,reader where reader.r_id=borrow.r_id and book.b_id=borrow.b_id

and book.p_id=publish.p_id and

pubname='中国铁道出版社' and b_name like '%SQL%'

21.查询借阅了“高等教育出版社”出版的书名中包含有“数据库”3个字的图书,但是没有借阅了“中国铁道出版社”出版的书名中含有“SQL”3个字的图书的读者姓名。 select r_name from book,borrow,publish,reader where reader.r_id=borrow.r_id and book.b_id=borrow.b_id and book.p_id=publish.p_id and pubname='高等教育出版社' and b_name like '%数据库%' minus

select r_name from book,borrow,publish,reader where reader.r_id=borrow.r_id and book.b_id=borrow.b_id

and book.p_id=publish.p_id and

pubname='中国铁道出版社' and b_name like '%SQL%'

【任务7】索引、视图、序列及同义词

1.为Book图书表的书名列创建惟一索引idx_Bname。 create unique index idx_bname on book(b_name) 2.将索引“idx_Bname”重命名为index_Bname。 alter index idx_bname rename to index_bname

3.删除索引index_Bname,将命令写在实验报告中。 drop index index_bname

4.建立“人民邮电出版社”所出版的图书视图V_Pub,视图中包含书号、书名、出版社信息。 grant create view to latto;

create view v_pub as select b_id,b_name,publish.* from book,publish where book.p_id=publish.p_id and pubname='人民邮电出版社'

5.创建一个借阅统计视图,名为V_Count_1,包含读者的借书证号和总借阅本数,要求该视