ImageVerifierCode 换一换
格式:DOC , 页数:8 ,大小:203.84KB ,
资源ID:5651029      下载积分:10 金币
快捷注册下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

开通VIP
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.zixin.com.cn/docdown/5651029.html】到电脑端继续下载(重复下载【60天内】不扣币)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

开通VIP折扣优惠下载文档

            查看会员权益                  [ 下载后找不到文档?]

填表反馈(24小时):  下载求助     关注领币    退款申请

开具发票请登录PC端进行申请

   平台协调中心        【在线客服】        免费申请共赢上传

权利声明

1、咨信平台为文档C2C交易模式,即用户上传的文档直接被用户下载,收益归上传人(含作者)所有;本站仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。所展示的作品文档包括内容和图片全部来源于网络用户和作者上传投稿,我们不确定上传用户享有完全著作权,根据《信息网络传播权保护条例》,如果侵犯了您的版权、权益或隐私,请联系我们,核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
2、文档的总页数、文档格式和文档大小以系统显示为准(内容中显示的页数不一定正确),网站客服只以系统显示的页数、文件格式、文档大小作为仲裁依据,个别因单元格分列造成显示页码不一将协商解决,平台无法对文档的真实性、完整性、权威性、准确性、专业性及其观点立场做任何保证或承诺,下载前须认真查看,确认无误后再购买,务必慎重购买;若有违法违纪将进行移交司法处理,若涉侵权平台将进行基本处罚并下架。
3、本站所有内容均由用户上传,付费前请自行鉴别,如您付费,意味着您已接受本站规则且自行承担风险,本站不进行额外附加服务,虚拟产品一经售出概不退款(未进行购买下载可退充值款),文档一经付费(服务费)、不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
4、如你看到网页展示的文档有www.zixin.com.cn水印,是因预览和防盗链等技术需要对页面进行转换压缩成图而已,我们并不对上传的文档进行任何编辑或修改,文档下载后都不会有水印标识(原文档上传前个别存留的除外),下载后原文更清晰;试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓;PPT和DOC文档可被视为“模板”,允许上传人保留章节、目录结构的情况下删减部份的内容;PDF文档不管是原文档转换或图片扫描而得,本站不作要求视为允许,下载前可先查看【教您几个在下载文档中可以更好的避免被坑】。
5、本文档所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用;网站提供的党政主题相关内容(国旗、国徽、党徽--等)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
6、文档遇到问题,请及时联系平台进行协调解决,联系【微信客服】、【QQ客服】,若有其他问题请点击或扫码反馈【服务填表】;文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“【版权申诉】”,意见反馈和侵权处理邮箱:1219186828@qq.com;也可以拔打客服电话:0574-28810668;投诉电话:18658249818。

注意事项

本文(数据库实验答案分析总结.doc)为本站上传会员【pc****0】主动上传,咨信网仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知咨信网(发送邮件至1219186828@qq.com、拔打电话4009-655-100或【 微信客服】、【 QQ客服】),核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载【60天内】不扣币。 服务填表

数据库实验答案分析总结.doc

1、 实验三 用SQL语句完成以下的要求(键表及插入数据的SQL语句见下面): create table student( Sno char(5) primary key, Sname char(10), Ssex char(2), Sage int, Sdept char(2)); create table Course( Cno char(1) primary key, Cname char(20), Cpno char(1), Ccredit int); create table SC( Sno char(5), Cno char(1),

2、 Grade int, primary key (sno,cno)); insert into student values('95001','李勇','男',20,'CS'); insert into student values('95002','刘晨','女',21,'IS'); insert into student values('95003','王敏','女',18,'MA'); insert into student values('95004','张力','男',19,'IS'); insert into Course values('1','数据库','5'

3、4); insert into Course values('2','数学',NULL,2); insert into Course values('3','信息系统','1',4); insert into Course values('4','操作系统','6',3); insert into Course values('5','数据结构','7',4); insert into Course values('6','数据处理',NULL,2); insert into Course values('7','PASCAL语言','6',4); insert into SC

4、 values('95001','1',92); insert into SC values('95001','2',85); insert into SC values('95001','3',88); insert into SC values('95002','2',90); insert into SC values('95003','3',85); 1.查询信息系(IS)的所有学生信息 select * from Student where Sdept='IS'; 2.查询选修了“数学”课的所有学生名单 select * from Student,Course

5、SC where Student.Sno=SC.Sno And Course.Cno=SC.Cno And Course.Cname='数学'; 3.查询至少选修了一门其直接先行课为5号课程的学生的姓名。 select Student.Sname from Student,Course,SC where Student.Sno=SC.Sno And Course.Cno=SC.Cno And Course.Cpno='5' 4.查询全体学生的姓名和出生年份。 select sname,2013-Student.Sage from Student 5.

6、查询所有姓王的学生。 select * from Student where Sname like '王%'; 6.查询选修了3号课程的学生姓名及成绩,并按成绩降序排序。 select Student.Sname,SC.Grade from Student,Course,SC where Student.Sno=SC.Sno and Course.Cno=So and o='3' order by sc.grade desc 7.查询全体学生情况,查询结果按所在系的系号升序排列,同一系中的学生按年龄降序排列。 select * from student o

7、rder by sdept, sage desc 8.计算2号课程的平均成绩。 select AVG(grade) from SC where cno='2'; 9.查询选修了2号课程的学生的最高成绩。 select MAX(grade) from SC where cno='2'; 10.求各个课程号及相应的选课人数。 select cno,COUNT(distinct sno) from SC group by cno 11.查询至少选修了3门课程以上的学生序号。 select sno from SC group by sno having COUNT(

8、)>=3; 12.查询“数据库”的间接先行课。 select second.cpno from Course as first,Course as second where first.cpno=second.Cno And first.Cname='数据库'; 13.查询其他系中比信息系某一学生年龄小的学生的姓名和年龄。 select distinct first.sname,first.sage from Student as first, Student as second where first.Sage9、S' and first.Sdept!='IS'; 14.查询出成绩最低学号最大的学生学号。 select max(sno) from SC where Grade=( select min(grade) from SC); 15.查询成绩高于学生平均成绩的记录。 select first.Grade from SC as first, SC as second group by first.Grade having first.Grade> AVG(second.Grade); 16.查询至少选修了1号课程和3号课程的学生学号。 (select sn

10、o from SC where Cno='1') intersect (select sno from SC where Cno='3'); 17.查询只选修了1号课程和3号课程的学生学号。 select sno from SC where Cno='1'and Sno in( select Sno from SC where Cno='2'and Sno in( select Sno from SC group by Sno having COUNT(sno)=2)); 18.查询没有选修1号课程的学生姓名。 select sname from stu

11、dent,sc where sc.sno not in (select sno from sc where cno='1') and sc.sno=student.sno 19.查询选修了全部课程的学生姓名。 select sname from student where student.sno in ( select sno from sc as one where not exists (select * from SC as two where not exists (select * from SC as three where

12、 three.Sno=one.Sno and three.Cno=two.Cno))); 20.查询至少选修了95002所选修的全部课程的学生学号。 select distinct sno from sc as one where not exists (select * from SC as two where two.sno='95002' and not exists (select * from SC as three where three.Sno=one.Sno and three.Cno=two.Cno)); 21.建立信息系学生视图,并从视图中查询年龄最大

13、的学生记录。 create view IS_student创建视图 as select * from Student where Sdept='IS'; select sno查询信息 from IS_student where sage in (select MAX(sage) from IS_student); 实验四 实验要求:下实验课后交一份实验报告,写明本次实验所用的SQL语句,并给出执行结果。 1.用SQL语句定义表student(sno,sname,ssex,sage),并加入如下约束: 主键:sno;sname有唯一约束;sname,ssex,sag

14、e都不允许空; 2.用SQL语句定义表course(cno,cname),并加入如下约束: 主键:cno;cname不允许空; 3.用SQL语句定义表sc(sno,cno,cj),并加入如下约束: 主键:sno,cno;为sno定义名为lsno的默认参照完整性;为cno定义名为lcno的默认参照完整性; 4.用SQL语句向student表输入如下元组: ('95001','李勇','男',20); ('95002','刘晨','女',21); 用SQL语句向course表输入如下元组: ('1','数据库'); ('2','数学'); 用SQL语句向sc表输入如下元组:

15、 ('95001','1',92); ('95001','2',85); ('95002','2',90); create table student( sno char(5) primary key, sname char(10) unique not null, ssex char(2) not null, sage int not null); create table course( cno char(1) primary key, cname char(20)not null); create table sc( sno char(5),

16、 cno char(1), cj int, primary key (sno,cno), constraint lsno foreign key (sno) references student(sno), constraint lcno foreign key (cno) references course(cno)); insert into student(sno,sname,ssex,sage)values('95001','李勇','男',20); insert into student(sno,sname,ssex,sage)values('95002'

17、'刘晨','女',21); insert into course(cno,cname) values('1','数据库'); insert into course(cno,cname) values('2','数学'); insert into sc(sno,cno,cj)values('95001','1','92'); insert into sc(sno,cno,cj)values('95001','2','85'); insert into sc(sno,cno,cj)values('95002','2','90'); 5.执行下列语句,并查看执行结果。如果不能

18、正确执行给出错误原因。 insert into student values('95001','张力','男',20);//错误的原因是学号已经存在,不允许插入重复的学号,违反了主键约束 insert into student values('95003','李勇','男',20);//错误原因是sname属性不允许出现重复键,违反了unique key约束 insert into SC values('95004','1',92);// INSERT语句与COLUMN FOREIGN KEY 约束 'lsno' 冲突,因为student 表中不存在这个学号 delete from s

19、tudent where sno='95001';//错误的原因是DELETE 语句与 COLUMN REFERENCE 约束 'lsno' 冲突。Restrict为默认选项,凡是被基本表所引用的主键不得删除 update course set cno='3' where cno='2';//错误的原因是UPDATE 语句与 COLUMN REFERENCE 约束 'lcno' 冲突。破坏了参照完整性。默认的不支持连级修改. 6.给student表的ssex列添加名为fm的约束,使其取值只能取'男'或'女'。 alter table student add constraint fn

20、 check(ssex in('男','女')); 执行insert into student values('95005','张力','f',20),查看执行结果。 INSERT 语句与 COLUMN CHECK 约束 'fn' 冲突。Sage属性只能为‘男’或‘女’。该语句违反了约束。 7.给student表的sage列添加约束,使其年龄不得超过20岁。查看约束是否能正确添加,并分析其原因。 不能,ALTER TABLE 语句与 COLUMN CHECK 约束 'fn1' 冲突。有的数据 大于 20 所以不能加上 约束! 8.删除约束lsno和lcno。 alter table

21、 sc drop constraint lcno,lsno; 9.为sc表添加在列sno上的外键约束lsno1,并定义为级联删除。执行delete from student where sno='95001';查看执行结果。 alter table sc add constraint lsno1 foreign key(sno)references student on delete cascade; sc中的关于95001的信息也被删除掉了。 10.为sc表添加在列cno上的外键约束lcno1,并定义为级联修改。执行update course set cno='3' where

22、cno='2';查看执行结果。 alter table sc add constraint lcon1 foreign key (cno)references course on update cascade; sc中的关于课程号2的被修改为了3。 实验五 有如下两个表: 教师(编号,姓名,性别,职称,工资,系别编号)  主码:编号 系别(系别编号,系名称,人数)  主码:系别编号 create table teacher (tno char(5)primary key, tname char(10), tsex char(2), tpos char(10), tsa

23、l int, xno char(4)); create table xibie (xno char(4)primary key, xname char(2), xcount int); insert into xibie(xno,xname,xcount)values('1001','CS',0); insert into xibie(xno,xname,xcount)values('1002','IS',0); insert into xibie(xno,xname,xcount)values('1003','NE',0); 要求利用触发器完成下面的功能: 1. 对教

24、师表进行插入、删除操作时维护系别人数。 create trigger tri_count on teacher for insert as update xibie set xcount=xcount+1 where xno= (select xno from inserted); create trigger tri_count1 on teacher for delete as update xibie set xcount=xcount-1 where xno=( select xno from deleted); 2. 教授工资不得低于1500。

25、 create trigger tri_salary on teacher for update,insert as if( select COUNT (*) from inserted where not exists (select * from inserted where inserted.tpos='教授' and inserted.tsal<1500))=0 rollback transaction 3. 工资只能增加不能减少。 create trigger tri_salary1 on teacher for update as if( select COUNT(*) from inserted,deleted where deleted.tsal

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2026 宁波自信网络信息技术有限公司  版权所有

客服电话:0574-28810668  投诉电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服