山东大学数据库实验答案2—8
山大数据库简答题整理
1、事务的定义及其特性答:事务是由一系列操作序列构成的程序执行单元,这些操作要么都做,要么都不做,是一个不可分割的工作单位。
事务的ACID特性:原子性(Atomicity) 事务中包含的所有操作要么全做,要么全不做一致性(Consistency) 事务的隔离执行必须保证数据库的一致性隔离性(Isolation) 系统必须保证事务不受其它并发执行事务的影响持久性(Durability) 一个事务一旦提交之后,它对数据库的影响必须是永久的。
2、完整性约束:数据库完整性(Database Integrity)是指数据库中数据的正确性、有效性和相容性。
数据库完整性由各种各样的完整性约束来保证,因此可以说数据库完整性设计就是数据库完整性约束的设计。
1、实体完整性:要求每个关系模式有且仅有一个主码,每个主码的值必须唯一,而且不能为空。
2、域完整性:数据库表中的列必须满足某种特定的数据类型或约束。
其中约束又包括取值范围、精度等规定。
表中的CHECK、FOREIGN KEY 约束和DEFAULT、 NOT NULL定义都属于域完整性的范畴。
3、参照完整性:参照的完整性要求关系中不允许引用不存在的实体。
当更新、删除、插入一个表中的数据时,通过参照引用相互关联的另一个表中的数据,来检查对表的数据操作是否正确。
3.DBMS数据库管理系统(Database Management System)是一种操纵和管理数据库的大型软件,用于建立、使用和维护数据库,简称DBMS。
它对数据库进行统一的管理和控制,以保证数据库的安全性和完整性。
用户通过DBMS访问数据库中的数据,数据库管理员也通过dbms进行数据库的维护工作。
它可使多个应用程序和用户用不同的方法在同时或不同时刻去建立,修改和询问数据库。
大部分DBMS提供数据定义语言DDL(Data Definition Language)和数据操作语言DML(Data Manipulation Language),供用户定义数据库的模式结构与权限约束,实现对数据的追加、删除等操作。
文献检索实验报告
实验1:各种类型中外文文献检索目的:1.学会电子图书检索。
2.学会中文学位论文检索。
3.学会中文会议论文检索。
4.学会中文期刊论文检索。
5.学会国内重要专业人士、重要研究机构、重要文献、重要期刊等信息检索。
6.学会标准文献检索。
7. 学会科技成果检索。
8. 学会外文期刊论文检索。
内容:1.自选检索课题。
2.分析检索课题,确定检索标识,编写提问式。
3.利用超星电子图书(免费阅览室)、、国家科技图书文献中心等相关数据库。
4. 在相关检索提问框中输入提问式实施检索,筛选命中文献,选择检索结果输出格式并输出结果。
如有必要可反复修改检索提问式优化检索结果。
5.记录检索过程,完成检索报告并提交。
要求:1.电子图书选择或其他电子书全文数据库中的1种数据库进行电子图书检索:数据库名称___超星电子图书(免费阅览室)_________检索策略(表达式)___TI=悲惨世界__________命中文献数____128________选取其中1条文献题录:书名:悲惨世界作者姓名:雨果出版时间:2006年12月第2版总页数:2552.中文学位论文选择中国知网数字出版平台——中国优秀硕士学位论文全文数据库、中国博士学位论文全文数据库、国家科技图书文献中心——中文学位论文等数据库中的1种数据库进行学位论文检索:数据库名称______中国优秀硕士学位论文全文数据库______________检索年限____________2010-2012_____________________检索策略(表达式)______su=电路原理___________________命中文献数_____42_______选取其中1条文献题录:论文题目:电力电子电路中快标分叉及混沌控制研究作者姓名:胡乃红导师姓名:陈军宁;周宇飞授予学位级别:博士作者专业名称:电路与系统学位授予单位:安徽大学授予学位时间:2012论文总页数:1013.会议论文选择中国知网数字出版平台——中国重要会议论文全文数据库、国家科技图书文献中心——中文会议论文等数据库中的1种数据库进行会议论文检索:数据库名称____中国重要会议论文全文数据库____________检索年限_____2010-2013_____________________检索策略(表达式)____ KV_=老年文学___________命中文献数____54________选取其中1条文献题录:论文题目:不断创新学会工作思路合力助推老龄事业发展作者姓名:陈跃第一作者单位:陕西省老年学学会会议名称:陕西老年学通讯会议地点:陕西省老年学学会主办单位:陕西省老年学学会∙出处(会议录名称、出版时间、论文在会议录中的页码范围):【会议时间】2013-01-01∙【分类号】D669.6-264.中文期刊论文选择中国知网数字出版平台——中国学术期刊网络出版总库、国家科技图书文献中心——中文期刊等数据库中的1种数据库进行中文电子期刊检索:数据库名称__中国学术期刊网络出版总库______检索年限_______201_________________检索策略(表达式)__SU_=高校建设______命中文献数____8________选取其中1条文献题录:论文题目:高校学科建设项目目标集成管理研究作者姓名:贾晓霞第一作者单位:上海海事大学经济管理学院出处(出版物名称、年、卷、期、页码范围):现代教育科学2012年11期5.国内重要专业人士、重要研究机构、重要文献、重要期刊等信息利用中国知网数字出版平台——中国学术期刊网络出版总库进行相关信息检索:数据库名称_中国知网数字出版平台——中国学术期刊网络出版总库_____检索年限_________2010-2012_________________________检索策略(表达式)____kv=文学________________________命中文献数_____980_______选取其中1条文献题录:(1)该领域重要作者(收录文献总数位于前三名):第一名:收录文献数量:8作者姓名:吴建民作者单位:徐州师范大学文学院第二名:收录文献数量:8作者姓名:金里作者单位:复旦大学第三名:收录文献数量:8作者姓名:王永平作者单位:扬州大学社会发展学院(2)该领域重要机构(收录文献总数位于前三名):第一名:收录文献数量:106单位名称:南京大学第二名:收录文献数量:106单位名称:四川大学第三名:收录文献数量:102单位名称:山东大学(3)该领域重要文献(文献被引频次位于前三名):第一名:文献题目:躲避崇高作者姓名:王蒙文献来源:读书发表时间:1993被引频次:208作者单位名称:第二名:文献题目:美国生态文学批评述略作者姓名:朱新福文献来源:当代外国文学发表时间:2003被引频次:145作者单位名称:苏州大学外国语学院第三名:文献题目:审美意识形态论作为文艺学的第一原理作者姓名:童庆炳文献来源:学术研究发表时间:2000被引频次:105作者单位名称:北京师范大学中文系(4)该领域重要中文期刊(收录文献总数位于前三名):第一名:收录文献数量:8632期刊名称:萌芽第二名:收录文献数量:6574期刊名称:小说月报第三名:收录文献数量:6340期刊名称:当代6.标准文献选择国家科技图书文献中心——标准检索、标准网——标准目录高级查询等数据库中的1种数据库进行标准检索:数据库名称___标准网——标准目录高级查询_________________检索年限___________2008—2012____________________检索策略(表达式)___SU=生物学_____________________命中文献数____124________选取其中1条文献题录:标准名称:淀粉水分测定烘箱法标准编号:GB/T 12087-2008起草单位或起草人:国家粮食局科学研究院实施日期:2008-10-01发布日期:2008-05-27分类号:X11标准文献页数:137.科技成果选择国家科技成果数据库国家科技成果网——成果高级检索、中国知网数字出版平台——国家科技成果数据库、国家科技图书文献中心——中国科技成果等数据库中的1种数据库进行科技成果检索:数据库名称_____国家科技成果数据库_______________检索年限_______2012________________________检索策略(表达式)_______KV_=通信技术_________命中文献数____59________选取其中1条文献题录:成果名称:高精度遥感卫星图像定位分析关键技术与应用分类号:【中图分类号】TP75【学科分类号】420.20完成单位:中国科学院研究生院成果公布日期:20128.外文期刊论文选择国家科技图书文献中心——西文期刊检索、中国知网数字出版平台——德国SPRINGER公司期刊数据库、Emerald管理学、经济学、工程学数据库等数据库中的1种数据库进行外文电子期刊检索:数据库名称_中国知网数字出版平台——德国SPRINGER公司期刊数据库__检索年限____2010——2012_____________检索策略(表达式)____su=生物医学_______命中文献数______52_____选取其中1条文献题录:论文题目:Spectral-domain optical coherence tomography in healed ocular toxoplasmosis作者姓名:(1) Sandeep Saxena(2) Ramit A. K. Rastogi(3) Kuldeep Vishvkarma(4) Sanjiv Hansraj(5) Carsten H. Meyer出处(出版物名称、年、卷、期、页码范围):Springer-Verlag Received: 2011-03-31;Published online: 2011-08-10; 109~111实验2:利用搜索引擎及网上免费资源检索相关课题的文献目的:1.学会搜索引擎高级检索的技巧2.学会网上免费资源的使用方法内容:1.自选检索课题。
山东大学数据库实验答案2—8
⼭东⼤学数据库实验答案2—8⼭东⼤学数据库实验答案2—8 CREATE TABLE test2_01 ASSELECT SID, NAMEFROM pub.STUDENTWHERE sid NOT IN(SELECT sid FROM pub.STUDENT_COURSE)CREATE TABLE test2_02 ASSELECT SID,NAMEFROM PUB.STUDENTWHERE SID IN(SELECT DISTINCT SIDFROM PUB.STUDENT_COURSEWHERE CID IN(SELECT CID FROM PUB.STUDENT_COURSE WHERESID='200900130417'))CREATE TABLE test2_03 ASselect SID,NAME from PUB.STUDENT where SID in ( select distinct SID from PUB.STUDENT_COURSE where CID in (select CID from PUB.COURSE where FCID='300002') )CREATE TABLE test2_04 ASselect SID,NAME from PUB.STUDENT where SID in ( select distinct SID from PUB.STUDENT_COURSE where CID in (select CID from PUB.COURSE where NAME='操作系统')intersectselect distinct SID from PUB.STUDENT_COURSE where CID in (select CID from PUB.COURSE where NAME='数据结构') )create table test2_05 aswith valid_stu(sid,name) as(select SID,NAME from PUB.STUDENT where AGE=20 and SID in (select SID from PUB.STUDENT_COURSE))select sid,name as name,ROUND(avg(score)) as avg_score,sum(score) as sum_score fromPUB.STUDENT_COURSE natural join valid_stu where SID in (select SID from valid_stu)group by SID,NAMEcreate table test2_06 asselect CID,(max(SCORE))max_score from PUB.STUDENT_COURSE group byCIDcreate table test2_07 asselect SID,NAME from PUB.STUDENT where(NAME not like '张%' and NAME not like '李%' and NAME not like '王%') create table test2_08 aswith xing(value) as (select substr(NAME,1,1) from PUB.STUDENT)select value as second_name,count(value) as p_count from xing group by valuecreate table test2_09 asselect distinct SID,NAME,SCORE from PUB.STUDENT_COURSE natural join PUB.STUDENTwhere CID ='300003';create table test2_10 asselect distinct SID,CID from PUB.STUDENT_COURSE where SID in (select SID from PUB.STUDENT_COURSE) /* 1 */create table test3_01 asselect * from pub.student_31 where regexp_like(SID,'^[0-9]+$')/* 2 */create table test3_02 asselect * from pub.student_31where to_number(substr(BIRTHDAY,8,2))+AGE=112/* 3 */create table test3_03 asselect * from pub.student_31where SEX is null or SEX='男' or SEX='⼥'/* 4 */create table test3_04 asselect * from pub.student_31where DNAME is not null and length(DNAME)>=3 and instr(DNAME,' ')<=0 /* 5 */create table test3_05 asselect * from pub.student_31where regexp_like(CLASS,'^[0-9]{4}$')/* 6 */create table test3_06 asselect * from pub.student_31where regexp_like(SID,'^[0-9]+$')and to_number(substr(BIRTHDAY,8,2))+AGE=112 and (SEX is null orSEX='男' or SEX='⼥')and (DNAME is not null and length(DNAME)>=3 and instr(DNAME,' ')<=0) and regexp_like(CLASS,'^[0-9]{4}$') and (instr(NAME,' ')<=0 and length(NAME)>=2)/* 7 */create table test3_07 asselect * from pub.student_course_32 where SID in (select SID from pub.student)/* 8 */create table test3_08 asselect * from pub.student_course_32 natural join pub.teacher_course /* 9 */create table test3_09 asselect * from pub.student_course_32 where SCORE>=0 and score <=100 /* 10 */create table test3_10 asselect * from pub.student_course_32 natural join pub.teacher_course where SID in (select SID from pub.student) and CID in (select CID from pub.course) and TID in (select TID from pub.teacher) and SCORE>=0 and score <=100/*-------------- test4_01 --------------*/ create table test4_01 as select * from pub.student_41;ALTER TABLE test4_01 ADD sum_score number;update test4_01 set sum_score=(select sum(score) from pub.student_course a wheretest4_01.sid=a.sid group by sid);/*-------------- test4_02 --------------*/create table test4_02 as select * from pub.student_41;ALTER TABLE test4_02 ADD avg_score number;update test4_02 set avg_score =(select round(avg(score),1) from pub.student_course a wheretest4_02.sid=a.sidgroup by sid);/*-------------- test4_03 --------------*/create table test4_03 as select * from pub.student_41;ALTER TABLE test4_03 ADD sum_credit number;update test4_03 set sum_credit =(with a as (select * from pub.student_course natural join pub.course) (select sum(credit) from awhere SCORE>=60 and test4_03.sid=a.sid group by sid) )/* 4 */create table test4_04 as select * from pub.student_41;update test4_04 set dname=(select did from pub.department wheretest4_04.dname=pub.department.dname)where dname in (select dname from pub.department);/* 5 */create table test4_05 as select * from pub.student_41;ALTER TABLE test4_05 add did varchar(2);ALTER TABLE test4_05 ADD sum_score number;ALTER TABLE test4_05 ADD avg_score number;ALTER TABLE test4_05 ADD sum_credit number;update test4_05 set sum_score=(select sum(score) from pub.student_course a wheretest4_05.sid=a.sid group by sid);update test4_05 set avg_score =(select round(avg(score),1) from pub.student_course a wheretest4_05.sid=a.sidgroup by sid);update test4_05 set sum_credit =(with a as (select * from pub.student_course natural join pub.course) (select sum(credit) from awhere SCORE>=60 and test4_05.sid=a.sid group by sid));update test4_05 set did =(select did from pub.department wherepub.department.dname=test4_05.dname) where dname in (select dname from pub.department);update test4_05 set did =(select did from pub.department_41 where pub.department_41.dname=test4_05.dname) where dname in (select dname from pub.department_41);update test4_05 set did ='00' where did is null;/* 6 */create table test4_06 as select * from pub.student_42;update test4_06 set name=replace(name,' ','');/* 7 */create table test4_07 as select * from pub.student_42;update test4_07 set SEX=substr(trim(SEX),1,1) where length(SEX)<>1;/* 8 */create table test4_08 as select * from pub.student_42;update test4_08 set CLASS=substr(CLASS,1,4) where length(CLASS)<>4;/* 9 */create table test4_09 as select * from pub.student_42;update test4_09 set AGE=112-to_number(substr(BIRTHDAY,8,2)) where AGE is null;/* 10 */create table test4_10 as select * from pub.student_42;update test4_10 set name=replace(name,' ',''),DNAME=replace(DNAME,' ','');update test4_10 set SEX=substr(trim(SEX),1,1) where length(SEX)<>1;update test4_10 set CLASS=substr(CLASS,1,4) where length(CLASS)<>4;update test4_10 set AGE=112-to_number(substr(BIRTHDAY,8,2)) where AGE is null;create table test5_10(test varchar(20),age numeric (3));insert into test5_10 values('结果1',88);insert into test5_10 values('结果2',90);insert into test5_10 values('结果3',90);insert into test5_10 values('结果4',86);insert into test5_10 values('结果5',90);insert into test5_10 values('结果6',90);insert into test5_10 values('结果7',86);insert into test5_10 values('结果8',86);insert into test5_10 values('结果9',76);insert into test5_10 values('结果10',86);/* 1 */create view test6_01 asselect sid,name,dname from pub.studentwhere age<20 and dname='物理学院' order by sid/* 2 */create view test6_02 aswith temp_table(sid,ss) as(select sid,sum(score) from pub.student_course group by sid) select sid,name,dname,ss as sum_score from pub.student natural join temp_table where class='2009' and dname='软件学院'/* 3 */create view test6_03 asselect * from pub.student_course natural join pub.student whereclass='2010' and dname='计算机科学与技术学院' and cid =(select cid from pub.course where name='操作系统')/* 4 */create view test6_04 asselect sid,/doc/06a78e778662caaedd3383c4bb4cf7ec4bfeb671.html from pub.student_course natural join pub.studentwhere score>90 and cid =(select cid from pub.course where name='数据库系统')/* 5 */create view test6_05 asselect sid,cid,name,score from pub.student_course natural joinpub.coursewhere sid in (select sid from pub.student where name='李龙')/* 6 */create view test6_06 aswith a as (select sid,count(*) as totc from pub.student_course group by sid)select sid,name from pub.student where sid in (select sid from a where totc>=(selectcount(*) from pub.course))/* 7 */create view test6_07 asselect * from test6_06 where sid not in (select distinct sid from pub.student_course where sid in(select sid from test6_06)and score<60)/* 8 */create view test6_08 asselect cid,name from pub.coursewhere fcid in (select cid from pub.course where credit=2)/* 9 */create view test6_09 aswith a(sid,sum_credit) as(select sid,sum(credit) as sum_creditfrom pub.student_course natural join pub.course where SCORE>=60 group by sid)select sid,name,sum_credit from pub.student natural join a where class='2010' and dname='化学与化⼯学院'/* 10 */create view test6_10 asselect cid,name from pub.coursewhere fcid in(select cid from pub.course where fcid is not null)/* 1 */create table test7_01 asselect First_name,count(*) as frequency from( select substr(NAME,2) as First_name from pub.student ) group by First_name /* 2 */create table test7_02 asselect letter,count(*) as frequency from(select substr(NAME,2,1) as letter from pub.studentunion allselect substr(NAME,3) as letter from pub.student wherelength(Name)=3 ) group by letter/* 3 */create table test7_03 aswith a as (select sid,sum(credit) as tot from pub.student_course natural join pub.course where SCORE>=60 group by sid),b as (select * from pub.student natural left join a),c as (select dname,class,count(sid) as p_count from b group by (dname,class)),d as (select dname,class,count(sid) as p_count1 from b where tot>=10 group by (dname,class)),e as (select dname,class,count(sid) as p_count2 from b where tot<10 or tot is null group by (dname,class))select * from c natural left join d natural join eupdate test7_03 set p_count1=0 where p_count1 is null;/* 4 */create view test7_04_v1 asselect * from pub.student natural left join(select sid,sum(credit) as tot from pub.student_course natural join pub.course where SCORE>=60 group by sid);create table test7_04 aswith b as (select * from test7_04_v1),c as (select dname,class,count(sid) as p_count from b group by (dname,class)),d as (select dname,class,count(sid) as p_count1 from b where class<=2008 and tot>=8 group by (dname,class)unionselect dname,class,count(sid) as p_count1 from b where class>2008 and tot>=10 group by (dname,class))select * from c natural left join d where dname is not null;alter table test7_04 add p_count2 NUMBER;update test7_04 set p_count2 = p_count - p_count1;/* 1 */create table test8_01 aswith A as(select DNAME,SCORE,NAME from(select CID,DNAME,SCORE from pub.student_course natural joinpub.student where dnameis not null) natural join pub.course),B as(select dname,round(avg(score)) as avg_ds_score from A where name='数据结构' groupby dname),C as(select dname,round(avg(score)) as avg_os_score from A where name='操作系统' groupby dname)select * from B natural join C/* 2 */create table test8_02 aswith a as(select sid from pub.student_course where cid=(select cid frompub.course where name='操作系统') intersectselect sid from pub.student_course where cid=(select cid frompub.course where name='数据结构')),b as (select a.sid,score as ds_score from pub.student_course,a where pub.student_course.sid=a.sid and cid=(select cid from pub.course where name='数据结构')),c as (select a.sid,score as os_score from pub.student_course,a where pub.student_course.sid=a.sid and cid=(select cid from pub.course where name='操作系统'))select sid,name,dname,ds_score,os_score from b natural join cnatural join pub.student where dname='计算机科学与技术学院' /* 3 */create table test8_03 aswith a as(select sid from pub.student_course where cid=(select cid frompub.course where name='操作系统') unionselect sid from pub.student_course where cid=(select cid frompub.course where name='数据结构')),b as (select a.sid,score as ds_score from pub.student_course,a where pub.student_course.sid=a.sid and cid=(select cid from pub.course where name='数据结构')),c as (select a.sid,score as os_score from pub.student_course,a wherepub.student_course.sid=a.sid and cid=(select cid from pub.course where name='操作系统'))select sid,name,dname,ds_score,os_score from b natural full join c natural join pub.student where dname='计算机科学与技术学院' /* 4 */create table test8_04 aswith a as(select sid from pub.student_course where cid=(select cid frompub.course where name='操作系统') unionselect sid from pub.student_course where cid=(select cid frompub.course where name='数据结构')),b as (select a.sid,score as ds_score from pub.student_course,a where pub.student_course.sid=a.sid and cid=(select cid from pub.course where name='数据结构')),c as (select a.sid,score as os_score from pub.student_course,a where pub.student_course.sid=a.sid and cid=(select cid from pub.course where name='操作系统'))select sid,name,dname,ds_score,os_score from b natural full join c natural full join pub.student where dname='计算机科学与技术学院'。
山东大学数据库实验答案
数据库实验(一)1、create table test1_teacher(tid char(6) primary key,name varchar(10) not null,sex char(2),age int, dname varchar(10) )create index index_table1 on test1_teacher(name);insert into test1_teacher values('100101','张老师','男',44,'计算机学院');insert into test1_teacher values('100102','李老师','女',45,'软件学院');insert into test1_teacher values('100103','马老师','男',46,'计算机学院');2、create table test1_student(sid char(12) primary key, name varchar(10) not null,sex char(2),age int, birthday date, dname varchar(10),class varchar(10))create index index_table2 on test1_student(name);insert into test1_student values('200800020101','王欣','女',19,to_date('19940202','yyyymmdd'),'计算机学院','2010');insert into test1_student values('200800020102','李华','女',20,to_date('19950303','yyyymmdd'),'软件学院','2009');insert into test1_student values('200800020103','赵岩','男',18,to_date('19960404','yyyymmdd'),'软件学院','2009');3、create table test1_course( cid char(6) primary key, name varchar(10) not null,fcid char(6),credit numeric(2,1) )create index index_table3 on test1_course(name);insert into test1_course values('300001','数据结构','',2);insert into test1_course values('300002','数据库','300001',2.5);insert into test1_course values('300003','操作系统','300001',4);4、 create table test1_student_course(sid char(12) , cid char(6) , score numeric(5,1), tid char(6), primary key(sid,cid),FOREIGN KEY (sid) REFERENCES test1_student(sid),FOREIGN KEY (cid) REFERENCES test1_course(cid),FOREIGN KEY (tid) REFERENCES test1_teacher(tid) )insert into test1_student_coursevalues('200800020101','300001',91.5,'100101');insert into test1_student_coursevalues('200800020101','300002',92.6,'100102');insert into test1_student_coursevalues('200800020101','300003',93.7,'100103');5、create table test1_teacher_course( tid char(6) , cid char(6) , primary key(tid,cid),FOREIGN KEY (tid) REFERENCES test1_teacher(tid),FOREIGN KEY (cid) REFERENCES test1_course(cid) )insert into test1_teacher_course values('100101','300001');insert into test1_teacher_course values('100102','300002');insert into test1_teacher_course values('100103','300003');数据库实验(二)检索查询1、create table test2_01 as select sid ,namefrom pub.studentwhere sid not in(select sid from pub.student_course)2、create table test2_02 as select distinct student.sid,namefrom pub.student, pub.student_coursewhere student_course.sid = student.sid and student_course.cid in (select cid from pub.student_course where sid='200900130417')3、create table test2_03 as select distinct student.sid,namefrom pub.student, pub.student_coursewhere student_course.sid = student.sid and student_course.cid in (select cid from pub.course where fcid='300002')4、create table test2_04 as select sid,namefrom pub.studentwhere sid in(select sidfrom pub.student_course,pub.coursewhere student_course.cid=course.cid and name ='操作系统')and sid in(select sidfrom pub.student_course,pub.coursewhere student_course.cid=course.cidand name ='数据结构')5.create table test2_05 as select student.sid,name,cast(avg(score) as numeric(5,0)) avg_score,sum(score) sum_scorefrom pub.student,pub.student_coursewhere student.sid = student_course.sid and age ='20'group by student.sid,name使用CAST: CAST ( expression AS data_type )使用CONVERT: CONVERT (data_type[(length)], expression [, style])6、create table test2_06 as select sid,max(score) max_scorefrom pub.student_coursegroup by cid7.create table test2_07 as select sid,namefrom pub.studentwhere name not in(select namefrom pub.studentwhere name like '张%' or name like '李%' or name like '王%')8、create table test2_08 as select substr(name,1,1) second_name,count(*) p_countfrom pub.studentgroup by substr(name,1,1)SUBSTR(string,start,count)取子字符串,从start开始(如果start是负数,从尾部开始),取count个.上述就是PL/SQL函数的解释,从中可以看出,是1开始从左开始取数;如果是负值,那么就从右开始取数。
山东大学数据库实验4
create table test4_04 as select * from pub.student_41
alter table test4_04
add avg_score numeric(4,1)
alter table test4_03
add sum_credit int
alter table test4_03
add did varchar(2)
create table use as
select sid,sum(credit) sumcredit
8. 将pub用户下的Student_42及数据复制到主用户的表test4_08中,对表中的数据进行整理,修复那些不规范的数据:
对班级列进行规范(需要先确定哪些班级不规范)。
9. 将pub用户下的Student_42及数据复制到主用户的表test4_09中,对表中的数据进行整理,修复那些不规范的数据:
年龄为空值的根据出生日期设置学生年龄(年龄=2012-出生年份),年龄不为空值的不要改变。
10. 将pub用户下的Student_42及数据复制到主用户的表test4_10中,对表中的数据进行整理,修复那些不规范的数据:
(1) 剔除姓名列中的所有空格;
(2) 剔除院系名称列中的所有空格;
(3) 对性别列进行规范(需要先确定哪些性别数据不规范,也就是那些和大多数不一样的就是不规范的);
where test4_03.sid=use.sid)
4. 将pub用户下表student_41及数据复制到主用户的表test4_04中,使用alter table语句为表增加五个列:“总成绩:sum_score”、 “平均成绩:avg_score”、“总学分:sum_credit”、“院系编号:did varchar(2) ”。
2022年山东大学数据科学与大数据技术专业《数据库系统原理》科目期末试卷B(有答案)
2022年山东大学数据科学与大数据技术专业《数据库系统原理》科目期末试卷B(有答案)一、填空题1、在SELECT命令中进行查询,若希望查询的结果不出现重复元组,应在SEL ECT语句中使用______保留字。
2、在SELECT命令中,______子句用于选择满足给定条件的元组,使用______子句可按指定列的值分组,同时使用______子句可提取满足条件的组。
3、对于非规范化的模式,经过转变为1NF,______,将1NF经过转变为2NF,______,将2NF经过转变为3NF______。
4、如图所示的关系R的候选码为;R中的函数依赖有;R属于范式。
一个关系R5、在设计局部E-R图时,由于各个子系统分别有不同的应用,而且往往是由不同的设计人员设计,所以各个局部E-R图之间难免有不一致的地方,称为冲突。
这些冲突主要有______、______和______3类。
6、某在SQL Server 2000数据库中有两张表:商品表(商品号,商品名,商品类别,成本价)和销售表(商品号,销售时间,销售数量,销售单价)。
用户需统计指定年份每类商品的销售总数量和销售总利润,要求只列出销售总利润最多的前三类商品的商品类别、销售总数量和销售总利润。
为了完成该统计操作,请按要求将下面的存储过程补充完整。
7、数据库系统是利用存储在外存上其他地方的______来重建被破坏的数据库。
方法主要有两种:______和______。
8、数据仓库创建后,首先从______中抽取所需要的数据到数据准备区,在数据准备区中经过净化处理______,再加载到数据仓库中,最后根据用户的需求将数据发布到______。
9、数据库管理系统的主要功能有______________、______________、数据库的运行管理以及数据库的建立和维护等4个方面。
10、数据仓库主要是供决策分析用的______,所涉及的数据操作主要是______,一般情况下不进行。
山大数据库简答题整理汇编
1、事务的定义及其特性答:事务是由一系列操作序列构成的程序执行单元,这些操作要么都做,要么都不做,是一个不可分割的工作单位。
事务的ACID特性:原子性(Atomicity) 事务中包含的所有操作要么全做,要么全不做一致性(Consistency) 事务的隔离执行必须保证数据库的一致性隔离性(Isolation) 系统必须保证事务不受其它并发执行事务的影响持久性(Durability) 一个事务一旦提交之后,它对数据库的影响必须是永久的。
2、完整性约束:数据库完整性(Database Integrity)是指数据库中数据的正确性、有效性和相容性。
数据库完整性由各种各样的完整性约束来保证,因此可以说数据库完整性设计就是数据库完整性约束的设计。
1、实体完整性:要求每个关系模式有且仅有一个主码,每个主码的值必须唯一,而且不能为空。
2、域完整性:数据库表中的列必须满足某种特定的数据类型或约束。
其中约束又包括取值范围、精度等规定。
表中的CHECK、FOREIGN KEY 约束和DEFAULT、 NOT NULL定义都属于域完整性的范畴。
3、参照完整性:参照的完整性要求关系中不允许引用不存在的实体。
当更新、删除、插入一个表中的数据时,通过参照引用相互关联的另一个表中的数据,来检查对表的数据操作是否正确。
3.DBMS数据库管理系统(Database Management System)是一种操纵和管理数据库的大型软件,用于建立、使用和维护数据库,简称DBMS。
它对数据库进行统一的管理和控制,以保证数据库的安全性和完整性。
用户通过DBMS访问数据库中的数据,数据库管理员也通过dbms进行数据库的维护工作。
它可使多个应用程序和用户用不同的方法在同时或不同时刻去建立,修改和询问数据库。
大部分DBMS提供数据定义语言DDL(Data Definition Language)和数据操作语言DML(Data Manipulation Language),供用户定义数据库的模式结构与权限约束,实现对数据的追加、删除等操作。
山东大学数据库DB实验8
create table test8_01 as select tmp.dname,tmp.avg_ds_score,tmp1.avg_os_score from tmp,tmp1 where tmp.dname=tmp1.dname
drop table tmp
drop table tmp1
2.create table tmp as select pub.student.sid,,dname,score as ds_score from pub.student,pub.student_course,pub.course where pub.student.sid=pub.student_course.sid and pub.course.cid=pub.student_course.cid and dname='计算机科学与技术学院' and ='数据结构' and in (select from pub.student,pub.student_course,pub.course where pub.student.sid=pub.student_course.sid and pub.course.cid=pub.student_course.cid and dname='计算机科学与技术学院' and ='操作系统')
数据库课后习题完整答案
习题参考答案第1章习题参考答案一、选择题1. C2. B3. D4. C5. D6. A7. A8. B9. D、10. B 11. C 12. D 13. A 14. D 15. B二、填空题1. 数据库系统2. 关系3. 物理独立性4. 操作系统5. 数据库管理系统(DBMS)6. 多对多7. 独立性8. 完整性控制9. 逻辑独立性10. 关系模型11. 概念结构(逻辑)12. 树有向图二维表嵌套和递归13. 宿主语言(或主语言)14. 数据字典15. 单用户结构主从式结构分布式结构客户/服务器结构浏览器/服务器结构第2章习题参考答案一、选择题1. A2. C3. C4. B5. B6. C7. B8. D9. C 10. A 11. B 12. A 13. A 14. D 15. D二、填空题1. 选择(选取)2. 交3. 相容(或是同类关系)4. 并差笛卡尔积选择投影5. 并差交笛卡尔积6. 选择投影连接7. σf(R)8. 关系代数关系演算9. 属性10. 同质11. 参照完整性12. 系编号系名称,电话,办公地点13. 元组关系域关系14. 主键外部关系键15. R和S没有公共的属性三、简答7.σtno=’T1’(T)*TC*C)(1)∏cno,cn(σage>18∧Sex=’男’ (S))(2)∏sno,sn,dept(σtn=’李力’(T)*TC*C)(3)∏cno,cn,ct(σsno=’s1’(S)*SC*C)(4)∏cno,cn,score(σsn=’钱尔’(S)*SC*∏cno,cn(C)) (5)∏cno,cn,score(σtn=’刘伟’(T)*TC)(6)∏sn,cno(S*SC)÷∏cno(σsn=’李思’(S))*C)(7)∏cno,cn(C)-∏cno,cn(SC*((8)∏cno,cn,sno(C*SC)÷∏sno(S)σcno=’c1’∨cno=’c2’ (SC)) (9)∏sno,sn,cno(S*SC)*∏cno((10)∏sno,sn,cno(S*SC)÷∏cno(C)第3章习题参考答案一、填空题1.结构化查询语言(Structured Query Language)2.数据查询、数据定义、数据操纵、数据控制3.外模式、模式、内模式4.数据库、事务日志5.NULL/NOT NULL、UNIQUE约束、PRIMARY KEY约束、FOREIGNKEY约束、CHECK约束6.聚集索引、非聚集索引7.连接字段8.行数9.定义10.系统权限、对象权限11.基本表、视图12.(1)INSERT INTO S VALUES('990010','李国栋','男',19)(2)INSERT INTO S(No,Name) VALUES('990009', '陈平')(3)UPDATE S SET Name='陈平' WHERE No='990009'(4)DELETE FROM S WHERE No='990008'(5)DELETE FROM S WHERE Name LIKE '陈%'13.CHAR(8) NOT NULL14.o=o15.ALTER TABLE StudentADDSGrade CHAR(10)二、选择题1. B2. A3. C4. B5. C6. C7. B8. D9. A 10. D第4章习题参考答案一、选择题1. B2. B3. D4. B5. C6. D7. B8. D9. C 10. A二、填空题1. 超键(或超码)2. 正确完备3. 属性集X的闭包X +函数依赖集F的闭包F +4. 平凡的函数依赖自反性5. {AD→C} φ6. 2NF 3NF BCNF7. 无损连接保持函数依赖8. AB BC BD9. B→φB→B B→C B→BC10. B→C A→D D→C11. AB1NF12. AD3NF三、简答题1、2、3、4、5、解(1)根据F对属性分类:L类属性:BD。
数据库原理(山东联盟) 智慧树网课章节测试答案
1、选择题:对于DB、DBS、DBMS的关系,下列哪一种描述是正确的()选项:A:DB包括DBS、DBMSB:DBS包括DB、DBMSC:DBMS包括DBS、DBD:DBS包括DB答案: 【DBS包括DB、DBMS】2、选择题:在数据库中存储的是()。
选项:A:数据B:信息C:数据与信息D:数据以及数据之间的联系答案: 【数据以及数据之间的联系】3、选择题:Oracle数据库是关系数据库。
()选项:A:对B:错答案: 【对】4、选择题:数据库管理员的主要职责是查询数据。
()选项:A:对B:错答案: 【错】5、选择题:文件系统与数据库系统的重要区别是数据库系统具有()。
选项:A:数据结构化B:数据无冗余C:数据共享性D:数据独立性答案: 【数据结构化】1、选择题:最常用的一种基本数据模型是关系数据模型,它用统一的()结构来表示实体及实体之间的联系。
选项:A:链表B:网络C:图D:二维表答案: 【二维表】2、选择题:若在实体R的诸属性中,属性A不是R的主键,是另一个实体S 的主键,则称A为R的()。
选项:A:候选码B:外键C:非主属性D:主属性答案: 【外键】3、选择题:自然连接是构成新关系的有效方法。
一般情况下,当对关系R和S使用自然连接时,要求R和S含有一个或多个共有的()。
选项:A:元组B:行C:记录D:属性答案: 【属性】4、选择题:关系运算中花费时间可能最长的运算是()。
选项:A:投影B:选择C:笛卡尔积D:除答案: 【笛卡尔积】5、选择题:外键约束必须和另一表中的主键约束共同使用。
( )选项:A:对B:错答案: 【对】1 【单选题】下面SELECT语句中哪个子句可以包含子查询。
AWHEREBORDERBYCSELECTDGROUPBY答案:WHERE2 【单选题】嵌套查询的子查询结果记录个数是。
A多个记录B一个记录C由子查询的WHERE子句而定D与FROM子句指定的表的记录个数相答案:由子查询的WHERE子句而定3 【单选题】在SQL中,数据更新语句是。
最新山东大学数据库习题及答案
山东大学数据库系统课程试卷A卷参考答案一、简答(每小题5分,共25分)1、如何理解空值(NULL),空值在参与运算时有哪些特点?答:空值null表示“不知道”或者“不存在”的含义。
不是指“0”,也不是“false”,也不是’’。
Null参与的关系运算和算术运算结果均为null。
评分细则:Null的含义3分,Null参与的运算特点2分2、简述事务的概念及其相关特性。
答:事物是访问并可能更新各种数据项的一个程序执行单元。
事物具有ACID四种特性。
A指原子性:事物的所有操作在数据库中要么全部正确反映出来,要么全部不反映。
C指一致性:事物的隔离执行保持数据库的一致性。
I指隔离性:尽管多个事物可以并发执行,但系统必须保证每一个事物都感觉不到系统中有其他事物在并发地执行。
D指持久性:一个事物成功完成后,它对数据库的改变必须是永久的。
评分细则:事物概念2分,事物的性质3分。
3、关系中的元组有先后顺序吗?为什么?答:没有。
关系是元组的集合,而集合中的元素是没有顺序的,因此关系中的元组也就没有先后顺序。
评分细则:第一问回答“有”,零分;第一问回答“没有”,2分,说明原因3分4、设关系模式R(A,B,C)上有一个多值依赖A B。
如果已知R的当前关系中存在着三个元组(a,b1,c1)、(a,b2,c2)、(a,b3,c3),那么这个关系中至少还应该存在哪些元组?答:(a b1 c2),(a b2 c1),(a b1 c3),(a b3 c1),(a b2 c3),(a b3 c2)评分细则:每一个元组1分。
5、简述时间戳排序协议。
答:时间戳:对于系统中的每一个事务Ti,我们把一个唯一的固定的时间戳和它联系起来,记为TS(Ti)。
每个数据项Q需要与两个时间戳相关联:W-timestamp(Q)表示成功执行write(Q)的所有失去的最大时间戳;R-timestamp(Q)表示成功执行read(Q)的所有事务的最大的时间戳。
山大数据库实验二
group by cid
create table test2_07 as
select sid,name
from pub.STUDENT
where not(name like '张%' or name like '李%'or name like '王%')
where STUDENT_COURSE.cid in(select cid
from pub.COURSE
where name='操作系统'))
intersect
(select sid
from pub.STUDENT_COURSE
where STUDENT_COURSE.cid in(select cid
create table test2_08 as
select substr(name,1,1) second_name, count(*) p_count
from pub.STUDENT
group by substr(name,1,1)
create table test2_09 as
select pub.STUDENT_COURSE.sid,name,score
from pub.STUDENT,pub.STUDENT_COURSE
where pub.STUDENT.SID=pub.STUDENT_COURSE.sid and cid=300003
create table test2_10 as
where pub.STUDENT.SID =s
create table test2_02 as select sid,name
山东大学数据库系统SQL上机实验代码test2——test8(最新版)
Test2(1)create table test2_01 as select sid,nameFrom pub.student pwhere not exists (select cid from pub.student_course where sid=p.sid)(2)create table test2_02 as select sid,nameFrom pub.student natural join pub.student_courseWhere cid in (select cid from pub.student_course where sid=’200900130417’)(3)create table test2_03 as select sid,nameFrom pub.student natural join pub.student_courseWhere cid in (select cid from pub.course where fcid=’300002’)(4)create table test2_04 as select sid,nameFrom pub.studentWhere sid in(select sid from pub.course ,pub .student_course where student_course.cid=course.cid and name='操作系统' )Andsid in(select sid from pub.course ,pub .student_course where student_course.cid=course.cid and name='数据结构' )(5)create table test2_05 as select student.sid,name,cast(avg(score) as numeric(5,0)) avg_score, sum (score) sum_scorefrom pub.student_course,pub.studentWhere pub.student_course.sid=pub.student.sid and age='20'group by student.sid,name(6)create table test2_06 as select cid,max(score)max_scoreFrom pub.student_courseGroup by cid(7)create table test2_07 as select sid,nameFrom pub.studentWhere name not in (select name from pub.student where name like (‘张%’) or name like (‘李%’) or name like (‘王%’)(8)create table test2_08 as select substr(name,1,1) second_name,count (*) p_countFrom pub.studentGroup by substr(name,1,1)(9)create table test2_09 as select pub.student.sid,name,scoreFrom pub.student,pub.student_courseWhere pub.student.sid=pub.student_course.sid and cid='300003'(10)create table test2_10 as select sid,cidFrom pub.student_courseWhere score is not nullTest3(1)create table test3_01 as select * from pub.Student_31delete from test3_01 where length(translate(sid,'\0123456789','\'))>0(2(create table test3_02 as select * from pub.Student_31delete from test3_02 where age<>2012-extract(year from birthday)delete from test3_03 where sex not in (select sex from test3_03 where sex='男' or sex='女' or sex=null)(4(create table test3_04 as select * from pub.Student_31delete from test3_04 where dname is null or length(dname)<3 or dname like '% %'(5(create table test3_05 as select * from pub.Student_31delete from test3_05 where length(class)>4(6(create table test3_06 as select * from pub.Student_31delete from test3_06 where length(translate(sid,'\0123456789','\'))<12Delete from test3_06 where age<>2012-extract(year from birthday)Delete from test3_06 where sex not in (select sex from test3_03 where sex='男' or sex='女' or sex=null) Delete from test3_06 where dname is null or length(dname)<3 or dname like '% %'delete from test3_06 where length(class)>4delete from test3_06 where name like '% %' or length(name)<2(7)create table test3_07 as select * from pub.Student_course_32delete from test3_07 where sid not in (select sid from pub.student)(8)create table test3_08 as select * from pub.Student_course_32delete from test3_08 where (cid,tid) not in (select cid,tid from pub.teacher_course)(9)create table test3_09 as select * from pub.Student_course_32delete from test3_09 where score <0 or score >100(10)create table test3_10 as select * from pub.Student_course_32delete from test3_10 where score <0 or score >100delete from test3_10 where sid not in (select sid from pub.student)delete from test3_10 where cid not in (select cid from pub.course)delete from test3_10 where tid not in (select tid from pub.teacher)delete from test3_10 where (cid,tid) not in (select cid,tid from pub.teacher_course)Test 4(1)create table test4_01 as select * from pub.student_41alter table test4_01 add sum_score numberupdate test4_01 set sum_score = (select sum (score) from pub.student_course where test4_01.sid= pub.student_course.sid)(2)create table test4_02 as select * from pub.student_41alter table test4_02 add avg_score numeric(5,1)update test4_02 set avg_score = (select avg (score) from pub.student_course where test4_02.sid= pub.student_course.sid)(3)create table test4_03 as select * from pub.student_41alter table test4_03 add sum_credit intcreate table t4_031 as select * from pub.course natural join pub.student_courseupdate t4_031 set credit=0 where score<60update test4_03 set sum_credit = (select sum(credit) from t4_031 where test4_03.sid=t4_031.sid) (4)create table test4_04 as select * from pub.student_41update test4_04 set dname=(select did from pub.department where pub.department.dname=test4_04.dname)where dname in (select dname from pub.department)alter table test4_05 add sum_score numberalter table test4_05 add avg_score numeric(5,1)alter table test4_05 add sum_credit intalter table test4_05 add did varchar(2)update test4_05 set sum_score =(select sum (score) from pub.student_course where test4_05.sid= pub.student_course.sid)update test4_05 set avg_score = (select avg (score) from pub.student_course where test4_05.sid= pub.student_course.sid)update test4_05 set sum_credit = (select sum(credit) from t4_031 where test4_05.sid=t4_031.sid) create table a1 as select * from pub.departmentinsert into a1 select * from pub.department_41 where dname not in (select distinct dname from pub.department )(6)create table test4_06 as select * from pub.student_42update test4_06 set name =replace(name,' ','')(7)create table test4_07 as select * from pub.student_42update test4_07 set sex =replace(sex,'性','')update test4_07 set sex =replace(sex,' ','')(8)create table test4_08 as select * from pub.student_42update test4_08 set class=replace(class,'级','')update test4_08 set class=replace(class,' ','')(9)create table test4_09 as select * from pub.student_42update test4_09 set age=2012-extract(year from birthday) where age is null(10)create table test4_10 as select * from pub.student_42update test4_10 set name=replace(name,' ','')update test4_10 set dname=replace(dname,' ','')update test4_10 set sex=replace(sex,'性','')update test4_10 set sex=replace(sex,' ','')update test4_10 set class=replace(class,'级','')update test4_10 set class=replace(class,' ','')update test4_10 set age=2012-extract(year from birthday) where age is nullTest5create table test5_10 (test varchar(20),age numeric (3))insert into test5_10values ('结果1',88),insert into test5_10values ('结果2',90),insert into test5_10values ('结果3',90),insert into test5_10values ('结果4',86),insert into test5_10values ('结果5',90),insert into test5_10values ('结果6',90),insert into test5_10values ('结果7',86),insert into test5_10values ('结果8',86),insert into test5_10values ('结果9',76),insert into test5_10values ('结果10',86)Test6(1) create view test6_01 as select sid,name,dname from pub.student where age<20 and dname='物理学院'order by sid(2)create view test6_02 as select pub.student.sid,name,sum(score)sum_score from pub.student,pub.student_course where pub.student.sid=pub.student_course.sid and class='2009' and dname='软件学院' group by pub.student.sid,(3)create view test6_03 as select pub.student.sid,,pub.student_course.score from pub.student,pub.student_course where pub.student.sid=pub.student_course.sid and class='2010' and dname='计算机科学与技术学院' and pub.student_course.cid=(select cid from pub.course where ='操作系统')(4)create view test6_04 as select pub.student.sid, from pub.student,pub.student_course where pub.student.sid=pub.student_course.sid and score>90 and pub.student_course.cid=(select cid from pub.course where ='数据库系统')(5)create view test6_05 as select pub.student_course.sid,pub.student_course.cid,score, from pub.course,pub.student_course,pub.student where pub.course.cid=pub.student_course.cid and pub.student_course.sid=pub.student.sid and ='李龙'(6)create view test6_06 as select sid,name from pub.student where sid in (select sid from pub.student_course group by sid having count(*) >=(select count(*) from pub.course ))(7)create view test6_07 as select sid,name from pub.student where sid in (select sid from pub.student_course where score>=60 group by sid having count(*) >=(select count(*) from pub.course ))(8)create view test6_08 as select a1.cid, from pub.course a1,pub.course a2 where a1.fcid =a2.cid and a2.credit=2(9)create view test6_09 as select pub.student.sid, ,sum(credit) sum_credit from pub.student, pub.student_course,pub.course where pub.student.sid = pub.student_course.sid and pub.student_course.cid=pub.course.cid and class='2010' and dname='化学与化工学院' and score>=60 group by pub.student.sid, (10)create view test6_10 as select a1.cid, from pub.course a1,pub.course a2 where a1.fcid =a2.cid and a2.fcid is not nullTest7(1)create table a as select (substr(name,2)) first_name from pub.student create table test7_01 as select first_name,(count(*)) frequency from a group by first_name(2)Union和Union All的区别之一在于对重复结果的处理。
山东大学数据仓库与数据挖掘_实验指导书(2014.10.28_16学时)
实验类型:综合性 实验学时:4 实验目的: 了解 Oracle 10g 和 Cognos 8 示例数据仓库环境的配置,熟悉 Cognos 软件的界面、操作和使用。 实验内容: 练习 1-1:了解 Oracle 10g 和 Cognos 8 示例数据仓库环境的配置。 练习 1-2:了解 Cognos Configuration 中数据库设定 。 练习 1-3:了解 Cognos 数据连接设定和添加 Cognos 业务库。 练习 1-4:了解 Cognos 8。 实验步骤: O接r设ac定l任e 、1务0报g1和.表1包.C了o还g解n原oO、s r8报ac示l表e例1测0数试g据和。仓C库og环no境s 8的示配例置数包据含仓以库下环几境个的部配分置:。数据库建立、实例数据表还原、数据连 在任安务装1.完1.成1.O在racOlreacDlaet建ab立as一e 个10编g后码,为就U要TF建8 的立数数据据库库。建立数据库的方法有两种,第一种是在命令行下 直接运行:dbca;第二种是点击开始菜单:开始=>程序=>Oracle=>oraDb10g_home1=>Configuration and M数管ig据理ra库模ti配板on置。T助在oo手安l=(装>DDaOatrtaaabcbalaseseedCaoCtnoafnbifagisugeruar1ta0itgoi的non时AsA候ssis如sits果atna没tn)t有用。建于立创数建据数库据(库一、般配创置建数时据就库把选项cm、数删据除库数建据立库好和, 数若据还库需。要为 Cognos 建立其他数据库,可以参考),在安装完成之后就可以使用数据库配置助手(DBCA)建立 ((注择12意U))T:若若F新8,oo建rraa如ccoll下eera9c图版ile以:本的及为数9据9ii以库以上时下版:版本本,,数则据数库据字库符字编符码编必码须和选国择家U字n符ico编de码(都AL要32选UTUF8T)F,8,而国家字符编码则选
数据库原理(山东联盟)智慧树知到课后章节答案2023年下山东科技大学
数据库原理(山东联盟)智慧树知到课后章节答案2023年下山东科技大学山东科技大学第一章测试1.对于DB、DBS、DBMS的关系,下列哪一种描述是正确的()答案:DBS包括DB、DBMS2.在数据库中存储的是()。
答案:数据以及数据之间的联系3.Oracle数据库是关系数据库。
()答案:对4.数据库管理员的主要职责是查询数据。
()答案:错5.文件系统与数据库系统的重要区别是数据库系统具有()。
答案:数据结构化第二章测试1.最常用的一种基本数据模型是关系数据模型,它用统一的()结构来表示实体及实体之间的联系。
答案:二维表2.若在实体R的诸属性中,属性A不是R的主键,是另一个实体S的主键,则称A为R的()。
答案:外键3.自然连接是构成新关系的有效方法。
一般情况下,当对关系R和S使用自然连接时,要求R和S含有一个或多个共有的()。
答案:属性4.关系运算中花费时间可能最长的运算是()。
答案:笛卡尔积5.外键约束必须和另一表中的主键约束共同使用。
( )答案:对第三章测试1.下面SELECT语句中哪个子句可以包含子查询。
答案:WHERE2.嵌套查询的子查询结果记录个数是。
答案:由子查询的WHERE子句而定3.在SQL中,数据更新语句是。
答案:UPDATE4.SQL中,“DELETE FROM 表名”表示( )。
答案:从基本表中删除所有元组5.下列聚合函数中,( )考虑空值。
答案:COUNT(* )第四章测试1.SQL语言集数据定义功能、数据操纵功能和效据控制功能于一体。
如下所列语句中,哪一个是属于数据控制功能的()答案:GRANT2.为了保证数据库的安全性,对一个数据库产品提供的授权定义中,提供的数据对象的() ,授权子系统就越灵活。
答案:粒度越小3.通过()可以把要保密的数据对无权存取的用户隐藏起来,从而对数据提供一定程度的安全保护。
答案:视图机制4.强制存取控制方法主要通过SQL语言的GRANT和REVOKE实现。
最新山大数据库简答题整理
最新⼭⼤数据库简答题整理1、事务的定义及其特性答:事务是由⼀系列操作序列构成的程序执⾏单元,这些操作要么都做,要么都不做,是⼀个不可分割的⼯作单位。
事务的ACID特性:原⼦性(Atomicity) 事务中包含的所有操作要么全做,要么全不做⼀致性(Consistency) 事务的隔离执⾏必须保证数据库的⼀致性隔离性(Isolation) 系统必须保证事务不受其它并发执⾏事务的影响持久性(Durability) ⼀个事务⼀旦提交之后,它对数据库的影响必须是永久的。
2、完整性约束:数据库完整性(Database Integrity)是指数据库中数据的正确性、有效性和相容性。
数据库完整性由各种各样的完整性约束来保证,因此可以说数据库完整性设计就是数据库完整性约束的设计。
1、实体完整性:要求每个关系模式有且仅有⼀个主码,每个主码的值必须唯⼀,⽽且不能为空。
2、域完整性:数据库表中的列必须满⾜某种特定的数据类型或约束。
其中约束⼜包括取值范围、精度等规定。
表中的CHECK、FOREIGN KEY 约束和DEFAULT、 NOT NULL定义都属于域完整性的范畴。
3、参照完整性:参照的完整性要求关系中不允许引⽤不存在的实体。
当更新、删除、插⼊⼀个表中的数据时,通过参照引⽤相互关联的另⼀个表中的数据,来检查对表的数据操作是否正确。
3.DBMS数据库管理系统(Database Management System)是⼀种操纵和管理数据库的⼤型软件,⽤于建⽴、使⽤和维护数据库,简称DBMS。
它对数据库进⾏统⼀的管理和控制,以保证数据库的安全性和完整性。
⽤户通过DBMS访问数据库中的数据,数据库管理员也通过dbms进⾏数据库的维护⼯作。
它可使多个应⽤程序和⽤户⽤不同的⽅法在同时或不同时刻去建⽴,修改和询问数据库。
⼤部分DBMS提供数据定义语⾔DDL(Data Definition Language)和数据操作语⾔DML(Data Manipulation Language),供⽤户定义数据库的模式结构与权限约束,实现对数据的追加、删除等操作。
数据库实验答案(樊辰自制,仅供参考)
create database StudentCoursegouse studentcoursego--在student数据库中,创建三张表create table students(Sno char(7) Primary Key,Sname varchar(8) NOT NULL,Ssex char(2),Sbirthday datetime,Sdept char(10),Smemo char(30))gocreate table courses(Cno char(4),Cname varchar(12),CpreCno char(4),Ccredit tinyint,constraint PK_course primary key(cno))gocreate table sc(Sno char(7) Foreign key references students(sno),Cno char(4) Foreign key references courses(cno),grade tinyint,primary key(sno,cno))go--分别向三张表中添加数据库insert into students values('0602001','钟振华','男','1987-05-01','计算机','优秀毕业生') insert into students values('0602002','吴家硕','女','1987-03-24','计算机','爱好:音乐') insert into students values('0602003','吴春斌','男','1988-07-01','计算机',NULL) insert into students values('0701001','王腾飞','男','1988-05-04','机电','爱好:音乐') insert into students values('0701002','林世伟','女','1987-04-03','机电','爱好:体育') insert into students values('0701003','李乐仪','女','1986-03-03','机电',null)insert into students values('0703001','李奇','男','1988-09-17','工商管理',null)goinsert courses values('c1','数据结构',null,4)insert courses values('c2','数据库原理','c1',4)insert courses values('c3','大型数据库','c2',3)insert courses values('c4','高尔夫',null,1)goinsert sc values('0602001','c1',61)insert sc values('0602001','c2',72)insert sc values('0602001','c3',88)insert sc values('0602002','c1',null)insert sc values('0602002','c2',61)insert sc values('0701001','c1',50)insert sc values('0701001','c2',null)insert sc values('0701002','c3',78)insert sc values('0701003','c1',52)insert sc values('0701003','c3',87)go--查询表中数据select * from studentsgo--删除表中数据delete scgo--删除表drop table studentsgo--3①查询计算机系全体学生的信息select *from Students--3②查询姓“李”的学生的学号和姓名。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
山东大学数据库实验答案2—8 CREATE TABLE test2_01 ASSELECT SID, NAMEFROM pub.STUDENTWHERE sid NOT IN(SELECT sid FROM pub.STUDENT_COURSE)CREATE TABLE test2_02 ASSELECT SID,NAMEFROM PUB.STUDENTWHERE SID IN(SELECT DISTINCT SIDFROM PUB.STUDENT_COURSEWHERE CID IN(SELECT CID FROM PUB.STUDENT_COURSE WHERESID='200900130417'))CREATE TABLE test2_03 ASselect SID,NAME from PUB.STUDENT where SID in ( select distinct SID from PUB.STUDENT_COURSE where CID in (select CID from PUB.COURSE where FCID='300002') )CREATE TABLE test2_04 ASselect SID,NAME from PUB.STUDENT where SID in ( select distinct SID from PUB.STUDENT_COURSE where CID in (select CID from PUB.COURSE where NAME='操作系统')intersectselect distinct SID from PUB.STUDENT_COURSE where CID in (select CID from PUB.COURSE where NAME='数据结构'))create table test2_05 aswith valid_stu(sid,name) as(select SID,NAME from PUB.STUDENT where AGE=20 and SID in (select SID from PUB.STUDENT_COURSE))select sid,name as name,ROUND(avg(score)) as avg_score,sum(score) as sum_score fromPUB.STUDENT_COURSE natural join valid_stu where SID in (select SID from valid_stu)group by SID,NAMEcreate table test2_06 asselect CID,(max(SCORE))max_score from PUB.STUDENT_COURSE group byCIDcreate table test2_07 asselect SID,NAME from PUB.STUDENT where(NAME not like '张%' and NAME not like '李%' and NAME not like '王%') create table test2_08 aswith xing(value) as (select substr(NAME,1,1) from PUB.STUDENT)select value as second_name,count(value) as p_count from xing group by valuecreate table test2_09 asselect distinct SID,NAME,SCORE from PUB.STUDENT_COURSE natural join PUB.STUDENTwhere CID ='300003';create table test2_10 asselect distinct SID,CID from PUB.STUDENT_COURSE where SID in (select SID from PUB.STUDENT_COURSE)/* 1 */create table test3_01 asselect * from pub.student_31 where regexp_like(SID,'^[0-9]+$')/* 2 */create table test3_02 asselect * from pub.student_31where to_number(substr(BIRTHDAY,8,2))+AGE=112/* 3 */create table test3_03 asselect * from pub.student_31where SEX is null or SEX='男' or SEX='女'/* 4 */create table test3_04 asselect * from pub.student_31where DNAME is not null and length(DNAME)>=3 and instr(DNAME,' ')<=0 /* 5 */create table test3_05 asselect * from pub.student_31where regexp_like(CLASS,'^[0-9]{4}$')/* 6 */create table test3_06 asselect * from pub.student_31where regexp_like(SID,'^[0-9]+$')and to_number(substr(BIRTHDAY,8,2))+AGE=112 and (SEX is null orSEX='男' or SEX='女')and (DNAME is not null and length(DNAME)>=3 and instr(DNAME,' ')<=0) and regexp_like(CLASS,'^[0-9]{4}$') and (instr(NAME,' ')<=0 and length(NAME)>=2)/* 7 */create table test3_07 asselect * from pub.student_course_32 where SID in (select SID from pub.student)/* 8 */create table test3_08 asselect * from pub.student_course_32 natural join pub.teacher_course /* 9 */create table test3_09 asselect * from pub.student_course_32 where SCORE>=0 and score <=100 /* 10 */create table test3_10 asselect * from pub.student_course_32 natural join pub.teacher_course where SID in (select SID from pub.student) and CID in (select CID from pub.course) and TID in (select TID from pub.teacher) and SCORE>=0 and score <=100/*-------------- test4_01 --------------*/ create table test4_01 as select * from pub.student_41;ALTER TABLE test4_01 ADD sum_score number;update test4_01 set sum_score=(select sum(score) from pub.student_course a wheretest4_01.sid=a.sid group by sid);/*-------------- test4_02 --------------*/create table test4_02 as select * from pub.student_41;ALTER TABLE test4_02 ADD avg_score number;update test4_02 set avg_score =(select round(avg(score),1) from pub.student_course a wheretest4_02.sid=a.sidgroup by sid);/*-------------- test4_03 --------------*/create table test4_03 as select * from pub.student_41;ALTER TABLE test4_03 ADD sum_credit number;update test4_03 set sum_credit =(with a as (select * from pub.student_course natural join pub.course) (select sum(credit) from awhere SCORE>=60 and test4_03.sid=a.sid group by sid) )/* 4 */create table test4_04 as select * from pub.student_41;update test4_04 set dname=(select did from pub.department wheretest4_04.dname=pub.department.dname)where dname in (select dname from pub.department);/* 5 */create table test4_05 as select * from pub.student_41;ALTER TABLE test4_05 add did varchar(2);ALTER TABLE test4_05 ADD sum_score number;ALTER TABLE test4_05 ADD avg_score number;ALTER TABLE test4_05 ADD sum_credit number;update test4_05 set sum_score=(select sum(score) from pub.student_course a wheretest4_05.sid=a.sid group by sid);update test4_05 set avg_score =(select round(avg(score),1) from pub.student_course a wheretest4_05.sid=a.sidgroup by sid);update test4_05 set sum_credit =(with a as (select * from pub.student_course natural join pub.course) (select sum(credit) from awhere SCORE>=60 and test4_05.sid=a.sid group by sid));update test4_05 set did =(select did from pub.department wherepub.department.dname=test4_05.dname) where dname in (select dname from pub.department);update test4_05 set did =(select did from pub.department_41 where pub.department_41.dname=test4_05.dname) where dname in (select dname from pub.department_41);update test4_05 set did ='00' where did is null;/* 6 */create table test4_06 as select * from pub.student_42;update test4_06 set name=replace(name,' ','');/* 7 */create table test4_07 as select * from pub.student_42;update test4_07 set SEX=substr(trim(SEX),1,1) where length(SEX)<>1;/* 8 */create table test4_08 as select * from pub.student_42;update test4_08 set CLASS=substr(CLASS,1,4) where length(CLASS)<>4;/* 9 */create table test4_09 as select * from pub.student_42;update test4_09 set AGE=112-to_number(substr(BIRTHDAY,8,2)) where AGE is null;/* 10 */create table test4_10 as select * from pub.student_42;update test4_10 set name=replace(name,' ',''),DNAME=replace(DNAME,' ','');update test4_10 set SEX=substr(trim(SEX),1,1) where length(SEX)<>1;update test4_10 set CLASS=substr(CLASS,1,4) where length(CLASS)<>4;update test4_10 set AGE=112-to_number(substr(BIRTHDAY,8,2)) where AGE is null;create table test5_10(test varchar(20),age numeric (3));insert into test5_10 values('结果1',88);insert into test5_10 values('结果2',90);insert into test5_10 values('结果3',90);insert into test5_10 values('结果4',86);insert into test5_10 values('结果5',90);insert into test5_10 values('结果6',90);insert into test5_10 values('结果7',86);insert into test5_10 values('结果8',86);insert into test5_10 values('结果9',76);insert into test5_10 values('结果10',86);/* 1 */create view test6_01 asselect sid,name,dname from pub.studentwhere age<20 and dname='物理学院' order by sid/* 2 */create view test6_02 aswith temp_table(sid,ss) as(select sid,sum(score) from pub.student_course group by sid) select sid,name,dname,ss as sum_score from pub.student natural join temp_table where class='2009' and dname='软件学院'/* 3 */create view test6_03 asselect * from pub.student_course natural join pub.student whereclass='2010' and dname='计算机科学与技术学院' and cid =(select cid from pub.course where name='操作系统')/* 4 */create view test6_04 asselect sid, from pub.student_course natural join pub.studentwhere score>90 and cid =(select cid from pub.course where name='数据库系统')/* 5 */create view test6_05 asselect sid,cid,name,score from pub.student_course natural joinpub.coursewhere sid in (select sid from pub.student where name='李龙')/* 6 */create view test6_06 aswith a as (select sid,count(*) as totc from pub.student_course group by sid)select sid,name from pub.student where sid in (select sid from a where totc>=(selectcount(*) from pub.course))/* 7 */create view test6_07 asselect * from test6_06 where sid not in (select distinct sid from pub.student_course where sid in(select sid from test6_06)and score<60)/* 8 */create view test6_08 asselect cid,name from pub.coursewhere fcid in (select cid from pub.course where credit=2)/* 9 */create view test6_09 aswith a(sid,sum_credit) as(select sid,sum(credit) as sum_creditfrom pub.student_course natural join pub.course where SCORE>=60 group by sid)select sid,name,sum_credit from pub.student natural join a where class='2010' and dname='化学与化工学院'/* 10 */create view test6_10 asselect cid,name from pub.coursewhere fcid in(select cid from pub.course where fcid is not null)/* 1 */create table test7_01 asselect First_name,count(*) as frequency from( select substr(NAME,2) as First_name from pub.student ) group by First_name/* 2 */create table test7_02 asselect letter,count(*) as frequency from(select substr(NAME,2,1) as letter from pub.studentunion allselect substr(NAME,3) as letter from pub.student wherelength(Name)=3 ) group by letter/* 3 */create table test7_03 aswith a as (select sid,sum(credit) as tot from pub.student_course natural join pub.course where SCORE>=60 group by sid),b as (select * from pub.student natural left join a),c as (select dname,class,count(sid) as p_count from b group by (dname,class)),d as (select dname,class,count(sid) as p_count1 from b where tot>=10 group by (dname,class)),e as (select dname,class,count(sid) as p_count2 from b where tot<10 or tot is null group by (dname,class))select * from c natural left join d natural join eupdate test7_03 set p_count1=0 where p_count1 is null;/* 4 */create view test7_04_v1 asselect * from pub.student natural left join(select sid,sum(credit) as tot from pub.student_course natural join pub.course where SCORE>=60 group by sid);create table test7_04 aswith b as (select * from test7_04_v1),c as (select dname,class,count(sid) as p_count from b group by (dname,class)),d as (select dname,class,count(sid) as p_count1 from b where class<=2008 and tot>=8 group by (dname,class)unionselect dname,class,count(sid) as p_count1 from b where class>2008 and tot>=10 group by (dname,class))select * from c natural left join d where dname is not null;alter table test7_04 add p_count2 NUMBER;update test7_04 set p_count2 = p_count - p_count1;/* 1 */create table test8_01 aswith A as(select DNAME,SCORE,NAME from(select CID,DNAME,SCORE from pub.student_course natural joinpub.student where dnameis not null) natural join pub.course),B as(select dname,round(avg(score)) as avg_ds_score from A where name='数据结构' groupby dname),C as(select dname,round(avg(score)) as avg_os_score from A where name='操作系统' groupby dname)select * from B natural join C/* 2 */create table test8_02 aswith a as(select sid from pub.student_course where cid=(select cid frompub.course where name='操作系统') intersectselect sid from pub.student_course where cid=(select cid frompub.course where name='数据结构')),b as (select a.sid,score as ds_score from pub.student_course,a where pub.student_course.sid=a.sid and cid=(select cid from pub.course where name='数据结构')),c as (select a.sid,score as os_score from pub.student_course,a where pub.student_course.sid=a.sid and cid=(select cid from pub.course where name='操作系统'))select sid,name,dname,ds_score,os_score from b natural join cnatural join pub.student where dname='计算机科学与技术学院' /* 3 */create table test8_03 aswith a as(select sid from pub.student_course where cid=(select cid frompub.course where name='操作系统') unionselect sid from pub.student_course where cid=(select cid frompub.course where name='数据结构')),b as (select a.sid,score as ds_score from pub.student_course,a where pub.student_course.sid=a.sid and cid=(select cid from pub.course where name='数据结构')),c as (select a.sid,score as os_score from pub.student_course,a wherepub.student_course.sid=a.sid and cid=(select cid from pub.course where name='操作系统'))select sid,name,dname,ds_score,os_score from b natural full join c natural join pub.student where dname='计算机科学与技术学院' /* 4 */create table test8_04 aswith a as(select sid from pub.student_course where cid=(select cid frompub.course where name='操作系统') unionselect sid from pub.student_course where cid=(select cid frompub.course where name='数据结构')),b as (select a.sid,score as ds_score from pub.student_course,a where pub.student_course.sid=a.sid and cid=(select cid from pub.course where name='数据结构')),c as (select a.sid,score as os_score from pub.student_course,a where pub.student_course.sid=a.sid and cid=(select cid from pub.course where name='操作系统'))select sid,name,dname,ds_score,os_score from b natural full join c natural full join pub.student where dname='计算机科学与技术学院'。