zoukankan      html  css  js  c++  java
  • 数据库笔试题1

    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 姓名;

  • 相关阅读:
    左孩子右兄弟的字典树
    UVA 1401 Remember the Word
    HDOJ 4770 Lights Against Dudely
    UvaLA 3938 "Ray, Pass me the dishes!"
    UVA
    Codeforces 215A A.Sereja and Coat Rack
    Codeforces 215B B.Sereja and Suffixes
    HDU 4788 Hard Disk Drive
    HDU 2095 find your present (2)
    图的连通性问题—学习笔记
  • 原文地址:https://www.cnblogs.com/wwwfj/p/3349330.html
Copyright © 2011-2022 走看看