文档详情

数据库上机考试题-含答案.doc

发布:2018-05-17约3.43千字共4页下载文档
文本预览下载声明
游戏开发商 Game_Company 结构: id Char(5) not null pk name varChar2(100) not null country varChar2(100) 数据: id name country 00001 世嘉 日本 00002 盛大 中国 00003 任天堂 美国 游戏 Game 结构: id Char(4) not null pk companyId Char(5) not null Fk :Game_Company的id name varChar2(100) not null type varChar2(50) 数据: id companyId name type 9001 00001 恶狼传说 格斗 9002 00001 樱花大战90% 益智 9003 00002 GT赛车 竞技 9004 00003 口袋妖怪 益智 9005 00003 俄罗斯方块 益智 9006 00003 马力欧 益智 9007 00003 口袋妖怪 竞技 游戏者 Player 结构: userid Char(3) not null pk username varChar2(50) not null gameid Char(4) not null Fk :Game_Company的id 数据: userid username gameid 001 张三 9003 002 李四 9002 003 陈奇 9001 004 王照 9005 005 郑明 9006 006 胡倩 9006 007 李梦 9007 008 马林 9006 创建game 表的结构;表名定义为表名+自己的姓名; create table database_java1_test.game_XXX ( id Char(4), companyId Char(5) not null, name varChar(100) not null, type varChar(50) ); 向game表中的主外键; alter table database_java1_test.game add primary key (`id`); alter table database_java1_test.game add constraint fk_game_company foreign key (`companyId`) references database_java1_test.game_company (`id`) ; 添加game表的数据;【9008, 00003, 超级玛丽, 动作】 Insert into game values (9008, 00003, 超级玛丽, 动作); 更新game表数据,把9008游戏名更新为’ 超级玛丽升级版’; Update game set name=超级玛丽升级版 where id=9008; 统计各个游戏类别的游戏数量; Select name, count(*) from game group by name; 查询每个游戏商家生产的游戏个数,以及厂商名,国家; select t0.id, , t0.country, t.totalnum from game_company t0, (select companyid, count(*) totalnum from game group by companyid) t where t0.id=panyid 查询玩家最少的游戏名; select t0.id, , t1.minnum from game t0, (select t.gameid, min(t.totalnum) minnum from (select gameid, count(*) totalnum from player group by gameid) t) t1 where t0.id=t1.gameid; 查询游戏名带有%的游戏 select * from game where name like %\%%; 查询没有人玩的游戏 select * from game g where g.id not in (select distinct p.gameid from player p) 查询玩家最多的三个游戏名; select t0.id, , t.totalnum from game t0, (select gameid, count(*) totalnum from player group by gameid order by totalnum desc,
显示全部
相似文档