createview A asselect * from Athlete
where Ateam='大连';
把对参赛表成绩的修改权限授予用户”USER1”
createuser USER1 identified by123456;grantupdate(Score) on Games to USER1;
查询”1002”号运动员参加的所有项目及比赛时间和地点,要求对查询结构按比赛时间的先后顺序排序
select Item.Ino, Iname, Itime, Iplace
from Item, Athlete, Games
where Item.Ino = Games.Ino and Athlete.Ano = Games.Ano and Athlete.Ano = '1002'orderby Itime;
查询参加”1000”号项目的所有运动员信息
select Games.Ano, Aname, Asex, Ateam
from Athlete, Games
where Games.Ano = Athlete.Ano and Games.Ino = '1000';
统计各队参加比赛的”男”运动员的人数分别是多少
select Ateam, count(Ano)
from Athlete
where Asex = '男'groupby Ateam;
查询不在”1”号场地比赛的项目名
select Iname from Item where Iplace != '1';
查询每个场地都有比赛的运动员号
select Athlete.Ano from
(select count(*) as cou from Item) temp,
Athlete,
(select Ano, count(*)as cou2 from Games groupby Ano) temp2
where temp2.Ano = Athlete.Ano and cou2 = cou;
查询参赛项目超过3项的”女”运动员的姓名
select Aname from
Athlete,
(select Ano, count(*) as cou from Games groupby Ano) temp2
where temp2.Ano = Athlete.Ano and cou >= 3and Asex = '女';
查询参加”跳高”比赛运动员的姓名和成绩
select Aname, Score
from Games, Athlete, Item
where Athlete.Ano = Games.Ano and Games.Ino = Item.Ino and Iname = '跳高';
求选课课程包含所有’801’号学生所修课程的学生的学号
select s.sno from
(select s.sno as sn, count(*) as cu from sc, s where sc.sno = s.sno groupby s.sno) t,
(select sno, count(*) as cu1 from sc
where cno != all(select cno from sc, s where sc.sno = s.sno and s.sno = '801')
groupby sno) t1,
(selectcount(*) as cu2 from sc, s
where sc.sno = s.sno and s.sno = '801'groupby s.sno) t2,
s
where
t.sn = s.sno
and
(
(t1.sno = s.sno
and
t.cu - t1.cu1 = t2.cu2)
or
t.cu = t2.cu2);