web数据困编程Word下载.docx
- 文档编号:17885943
- 上传时间:2022-12-11
- 格式:DOCX
- 页数:10
- 大小:17.94KB
web数据困编程Word下载.docx
《web数据困编程Word下载.docx》由会员分享,可在线阅读,更多相关《web数据困编程Word下载.docx(10页珍藏版)》请在冰豆网上搜索。
女'
CS'
20);
802'
文章'
男'
MA'
803'
张惠妹'
22);
804'
马伊利'
29);
805'
王二小'
null,19);
806'
王小波'
16);
807'
李银河'
19);
808'
苏小妹'
809'
李宇春'
21);
810'
刘德华'
null,22);
createtablec(
cnochar(3)primarykey,
cnamevarchar2(20),
creditint
insertintocvalues('
01'
数据库'
3);
02'
OS'
4);
03'
C++'
2);
04'
Java'
createtablesc(
snochar(4),
cnochar(3),
gradenumeric(3),
constraintsc_pkprimarykey(sno,cno),
constraintsc_fk1foreignkey(sno)referencess(sno),
constraintsc_fk2foreignkey(cno)referencesc(cno),
constraintsc_gradecheck(gradebetween0and100orgradeisnull)
insertintoscvalues('
81);
null);
92);
68);
59);
61);
commit;
select*froms;
select*fromc;
select*fromsc;
2、查询年龄小于18岁男生的名字和年龄。
selectsname,age
froms
whereage<
18andsex='
;
3、查询学分不小于4的课程的课程号、课程名和学分。
selectcno,cname,credit
fromc
wherecredit>
=4;
4、查询学生选课情况(列出学号、姓名、课程号、成绩;
要求选课和未选课的学生信息都要列出来)
selects.sno,sname,o,grade
froms,sc
wheres.sno=sc.sno
union
selectsno,sname
wheresnonotin(selectsno
fromsc
wherecnoisnotnull);
5、查询“刘德华”选学“数据库”的成绩。
selectgrade
wheresnoin(selectsnofromswheresname='
)
andcnoin(selectcnofromcwherecname='
6、查询没有选修“数据库”课程的学生信息(学号、姓名、性别)。
selectsno,sname,sex
fromscwherecno=(selectcno
fromc
wherecname='
));
7、查询至少选修了“数据库”和“操作系统”课程的学生的学号和姓名。
wheresnoin(selectsno
fromsc
wherecno=(selectcno
)
andsnoin(selectsno
)));
8、查询至少有一门课程不及格的学生的姓名和成绩。
selects.sname,grade
froms,sc
wheres.sno=sc.snoandgrade<
60;
9、查询没有“挂科”(成绩<
60)学生的学号和姓名。
***
wheregrade<
60);
10、统计学生的人数和平均年龄。
selectcount(*),avg(age)
froms;
11、查询男生中最大年龄和最小年龄。
selectmax(age),min(age)
wheresex='
12、统计已选课的学生人数。
selectcount(distinctsno)
fromsc;
13、统计从未选课的学生人数。
selectcount(sno)
wheresnonotin(selectsno
wherecnoisnotnull);
14、统计目前学生已选修的课程门数。
selectcount(distinctcno)
15、查询课容量小于70的课程名称和学分。
selectcname,credit
where(selectcount(*)
wherecno=o)<
70;
16、统计每个年龄所对应的学生人数。
selectage,count(*)
groupbyage;
17、查询每门课选课的人数,给出课程号和人数。
selectcno,count(*)
groupbycno;
18、查询每个学生选课的门数,给出学号和课程门数。
selectsno,count(*)
groupbysno;
19、查询选课门数超过15的学生,给出学号,姓名和性别。
####
fromswhere(selectcount(*)
wheresno=s.sno)>
15;
20、查询课程的名称和学分,该课程的选修人数在100至150之间。
selectcno,credit
where1<
=(selectcount(*)
wherecno=o)
and(selectcount(*)
=3;
21、查询男女生的平均成绩个是多少。
selectavg(grade)
froms
wheresex='
查询每个人的平均成绩:
selectsno,avg(grade)
22、查询平均成绩比每个女生平均成绩都高的男生的姓名和平均成绩。
selectsname,avg(grade)
wheres.sno=sc.snoandsex='
groupbysname
havingavg(grade)>
=(selectavg(grade)
23、查询平均成绩不及格的学生的学号、姓名和性别。
where(selectavg(grade)
fromsc
wheresno=s.sno)<
24、查询总成绩最高的学生的学号、姓名和性别。
where(selectsum(grade)
wheresno=s.sno)>
=all(selectsum(grade)
groupbysno);
25、查询所有的学生都选修的课程。
selectcno
wherecnoin(selectcno
groupbycno
havingcount(cno)=(selectcount(*)
froms));
26、学生成绩排榜(平均成绩从大到小顺序)。
groupbysno
orderbyavg(grade)desc;
27、查询平均成绩不算最低的学生姓名和学号。
****
fromswhere(selectavg(grade)
some(selectavg(grade)
28、将选修“数据库”课程的全体学生的成绩置零
updatescsetgrade=0
wherecno=1;
29、删除计算机专业所有学生的选课记录
delete
wheredept='
30、建立计算机系选修了“数据库”课程且成绩在90分以上的学生的视图
createviews_sc
asselectsno,cno,grade
wherecno=1andgrade>
select*froms_sc;
31、把查询student表和修改学生学号的权限授给用户U4
connectsystem/system;
dropuserU4cascade;
createuserU4identifiedbyU4;
grantCreateSessiontoU4;
grantselectonstoU4;
grantupdate(sno)onstoU4;
connectU4/U4;
select*fromsystem.s;
updatesystem.ssetsno=sno+1;
32、建立账户U4,然后授予对话(session)和建立数据表的权利;
在此基础上,实现查询超级用户(如System)中student表的信息(查阅oracle相应文档)
grantCreateTabletoU4;
grantUnlimitedTablespacetoU4;
connectU4/U4;
droptablestudent;
createtablestudent(
insertintostudentvalues('
王五'
赵六'
钱七'
select*fromstudent;
33题暂时不做
33、假设教师表模式描述如下
Teacher(eno,ename,sex,titlte,salary)
试建立触发器,定义完整性规则:
“教授的工资不低于4000,否则自动变为4000”
在此基础上,增加约束为教授的工资只能增加不不能减少,你能实现吗?
试试看
要求:
1、使用Oracle提供的操作符和函数,如自然连接jion、外连接等
2、学生根据自己实际水平,自行选题,最后都要完成题目,只是时间不同
3、采用多种方法完成题目。
例如使用连接查询(含外连接)、嵌套查询(相关
子查询和不相关子查询);
鼓励大胆使用带有any或all或exists谓词的子
查询
4、熟练掌握select语句的一般形式。
重点掌握聚集函数的使用方法;
where<
条件表达式>
、分组、having<
在解决查询问题中的使用技巧
5、题目标记,由易到难分别是:
无标记、***、####
6、考核方法:
提交电子版作业,第四周周一验收记分(第一次作业的分数)
郑海旭2012.3.2
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- web 数据 编程
![提示](https://static.bdocx.com/images/bang_tan.gif)