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 姓名;
更多文章、技術交流、商務合作、聯系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號聯系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元
