数据库笔试题1

系统 1641 0

1.如何删除表的某一列

alter table xxx drop colomn xxx;

2.增加某一列

alter table xxx add columnname type;

eg:alter table student add age number;

3.修改某一列

alter table xxx modify (columname type);//括号可要可不要

4.修改表名

rename oldtable to newtable;

5.2张表,stu(sid,sname)和ac(aid,sid,aname,score),分表为学生id,学生姓名,成绩id,科目,分数

1).查询数学成绩大于85的前5到10名的学生

select sname from (select sname,rownum r from (select sname from  stu,ac where stu.sid=ac.sid and aname='数学'and score>85 order by score desc)) newtable where r between 5 and 10;

注意rownum不能取大于,只能取小于,所以要给他新构建一个别名

2).查询所有科目都大于85分的学生姓名

select distinct(sname) from stu,ac where stu.sid=ac.sid and ac.sid not in(select sid from ac where score<=85)

3).让如下格式打印学生成绩

姓名    数学   语文    物理

张三     88     67      98

...     ...     ...     ...

select 姓名,sum(数学) 数学,sum(语文) 语文,sum(物理) 物理 from (select sname 姓名,decode(aname,'数学',score) 数学,decode(aname,'语文',score) 语文,decode(aname,'物理',score) 物理 from stu,ac where stu.sid=ac.sid ) group by 姓名;

数据库笔试题1


更多文章、技术交流、商务合作、联系博主

微信扫码或搜索:z360901061

微信扫一扫加我为好友

QQ号联系: 360901061

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描下面二维码支持博主2元、5元、10元、20元等您想捐的金额吧,狠狠点击下面给点支持吧,站长非常感激您!手机微信长按不能支付解决办法:请将微信支付二维码保存到相册,切换到微信,然后点击微信右上角扫一扫功能,选择支付二维码完成支付。

【本文对您有帮助就好】

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描上面二维码支持博主2元、5元、10元、自定义金额等您想捐的金额吧,站长会非常 感谢您的哦!!!

发表我的评论
最新评论 总共0条评论