MongoDB数据库开发-题库带答案
MongoDB数据库开发-题库带答案
MongoDB数据库开发-题库带答案
1、创建数据库mydb,给指定的集合添加⽂档。
db.students.insertMany([
{"_id":"1001","name":"程明","sex":"男","age":19,"major":"计算机应⽤技术","credits":52,score:92}, {"_id":"1002","name":"刘萍","sex":"⼥","age":18,"major":"移动应⽤开发","credits":51,score:88}, {"_id":"1003","name":"张静","sex":"⼥","age":20,"major":"计算机应⽤技术","credits":48,score:96}, {"_id":"1004","name":"陈好","sex":"⼥","age":20,"major":"软件技术","credits":53,score:97},
{"_id":"1005","name":"施⾏","sex":"男","age":20,"major":"计算机应⽤技术","credits":54,score:60}, {"_id":"1006","name":"刘⽂平","sex":"⼥","age":18,"major":"软件技术","credits":50,score:86}, {"_id":"1007","name":"李德胜","sex":"男","age":20,"major":"计算机应⽤技术","credits":55,score:95}, {"_id":"1008","name":"苏锦州","sex":"男","age":18,"major":"移动应⽤开发","credits":50,score:70}, {"_id":"1009","name":"张⽂杰","sex":"⼥","age":20,"major":"软件技术","credits":53,score:40}, {"_id":"1010","name":"王林","sex":"男","age":18,"major":"移动应⽤开发","credits":47,score:87}, {"_id":"1011","name":"程梦凡","sex":"男","age":19,"major":"软件技
术","credits":46,score:66}, {"_id":"1012","name":"陈⽟婷","sex":"⼥","age":19,"major":"计算机应⽤技术","credits":45,score:82}, {"_id":"1013","name":"张春华","sex":"男","age":19,"major":"软件技术","credits":45,score:64}, {"_id":"1014","name":"苏秦","sex":"⼥","age":18,"major":"计算机应⽤技术","credits":41,score:77}, {"_id":"1015","name":"李⾬桐","sex":"男","age":21,"major":"移动应⽤开发","credits":49,score:81}, {"_id":"1016","name":"唐开平","sex":"⼥","age":18,"major":"软件技术","credits":42,score:74}, {"_id":"1017","name":"罗世杰","sex":"男","age":21,"major":"移动应⽤开发","credits":57,score:64}, {"_id":"1018","name":"张可欣","sex":"⼥","age":20,"major":"计算机应⽤技术","credits":54,score:47}, {"_id":"1019","name":"刘柔","sex":"男","age":22,"major":"移动应⽤开发","credits":61,score:81}, {"_id":"1020","name":"王可可","sex":"⼥","age":17,"major":"计算机应⽤技术","credits":37,score:67}, {"_id":"1021","name":"王林","sex":"男","age":21,"major":"移动应⽤开发","credits":61,score:95}
])
答案:
10、mongoDB服务端默认的端⼝号是()
答案:
27017
11、关于Mongodb下列说法不正确的是()
A、启动客户端⽤mongo命令
B、 MongoDB是关系型数据库
C、 MongoDB⽀持海量数据存储
D、 MongoDB中每个⽂档都有_id字段
答案: B
12、添加⽂档是save和insert的区别在于如果_id对应的值已经存在,save直接更新,insert则报主键重复错误。
答案:正确
13、$inc修改器除了⽤于数值型数据,还可以⽤于字符串型数据。
答案:错误
14、将张三这条⽂档中的年龄字段删除应该使⽤哪个修改器?
15、在学⽣集合中按成绩的升序建⽴索引的语句为:sureIndex({"score":1})
答案:正确
16、切换数据库⽤()命令
答案:
use
17、在sort( )命令中升序⽤-1表⽰。
答案:错误
中国达人秀冠军
18、将普通集合转换为固定集合要⽤convertToCapped完成。
答案:正确
19、请写出启动MongoDB客户端的命令()
答案:
mongo
20、删除集合students的命令为()
答案:
db.students.drop();db.students.drop( )
21、$pop可以删除数组中的第⼀个元素或者最后⼀个元素。
答案:正确
22、MongoDB是关系型数据库。
答案:错误
23、移除⽂档中的某个字段应该⽤()修改器
答案:
$unset
24、字段重命名⽤$rename修改器
答案:正确
25、db表⽰查看当前数据库
答案:正确
26、db.students.insert({"name":"张三"})该语句没有指定_id字段,运⾏会出错。
答案:错误
27、打开MongoDB,打开服务,连上客户端,切换到exam数据库,只需截切换到exam数据库这条命令及结果。
28、向students集合中添加如下⽂档:
{"_id":"1001","name":"程明","sex":"男","age":19,"major":"计算机应⽤技术","credits":52,score:92} {"_id":"1002","name":"刘萍","sex":"⼥","age":18,"major":"移动应⽤开发","credits":51,score:88}
{"_id":"1003","name":"张静","sex":"⼥","age":20,"major":"计算机应⽤技术","credits":48,score:96} {"_id":"1004","name":"陈好","sex":"⼥","age":20,"major":"软件技术","credits":53,score:97}
{"_id":"1005","name":"施⾏","sex":"男","age":20,"major":"计算机应⽤技术","credits":54,score:60} {"_id":"1006","name":"刘⽂平","sex":"⼥","age":18,"major":"软件技术","credits":50,score:86}
{"_id":"1007","name":"李德胜","sex":"男","age":20,"major":"计算机应⽤技术","credits":55,score:95} {"_id":"1008","name":"苏锦州","sex":"男","age":18,"major":"移动应⽤开发","credits":50,score:70} {"_id":"1009","name":"张⽂杰","sex":"⼥","age":20,"major":"软件技术","credits":53,score:40}
{"_id":"1010","name":"王林","sex":"男","age":18,"major":"移动应⽤开发","credits":47,score:87}
答案:
29、请⽤查询语句显⽰计算机应⽤技术专业的学⽣⼈数。
答案:
30、请⽤查询语句显⽰年龄⼤于19岁的⼥⽣信息。
答案:
31、请⽤查询语句显⽰计算机应⽤技术和软件技术专业成绩⼤于90分的学⽣姓名、性别、专业和成绩
答案:
32、请⽤查询语句显⽰移动应⽤开发专业和计算机应⽤技术专业年龄为19-20岁⼥⽣的姓名、性别和成绩答案:
33、请将陈好的专业(major)修改为移动应⽤开发。
答案:
34、请给软件技术专业的所有⼥⽣添加⼀个字段course,值为MongoDB
答案:
35、请将李德胜的年龄减少2岁
答案:
36、请删除计算机应⽤技术专业男⽣的成绩(score)字段
答案:
37、请删除所有成绩不及格的学⽣信息。
答案:
38、查询所有男⽣的姓名,性别,年龄信息,并且按照年龄的降序显⽰
答案:
39、请查询成绩最好的学⽣的姓名,年龄,专业和成绩信息
40、查所有学⽣信息,按照专业升序,年龄降序排列。
41、请删除学⽣集合。
答案:
42、向students集合中添加如下⽂档:
{"_id":"1001","name":"程明","sex":"男","age":19,"major":"计算机应⽤技术","credits":52,score:92}
{"_id":"1002","name":"刘萍","sex":"⼥","age":18,"major":"移动应⽤开发","credits":51,score:88}
{"_id":"1003","name":"张静","sex":"⼥","age":20,"major":"计算机应⽤技术","credits":48,score:96}
{"_id":"1004","name":"陈好","sex":"⼥","age":20,"major":"软件技术","credits":53,score:97}
{"_id":"1005","name":"施⾏","sex":"男","age":20,"major":"计算机应⽤技术","credits":54,score:60}
{"_id":"1006","name":"刘⽂平","sex":"⼥","age":18,"major":"软件技术","credits":50,score:86}
{"_id":"1007","name":"李德胜","sex":"男","age":20,"major":"计算机应⽤技术","credits":55,score:95}
{"_id":"1008","name":"苏锦州","sex":"男","age":18,"major":"移动应⽤开发","credits":50,score:70}
{"_id":"1009","name":"张⽂杰","sex":"⼥","age":20,"major":"软件技术","credits":53,score:40}
{"_id":"1010","name":"王林","sex":"男","age":18,"major":"移动应⽤开发","credits":47,score:87}
答案:
43、请⽤查询语句显⽰计算机应⽤技术专业的学⽣⼈数。
答案:
44、查所有学⽣信息,按照专业升序,年龄降序排列。
答案:
45、爬取中国电影票房⽹(www.doczj/doc/8849a1d8cec789eb172ded630b1c59eef9c79a6a.html /),分析⽹页内容,爬取电影名称、当⽇排⽚、当⽇⼈次、当⽇预售票房、实时累积票房等数据,并将数据存储到MongoDB数据库中。
答案:
46、爬取“世界⼤学城空间”留⾔板⽹页信息
(www.doczj/doc/8849a1d8cec789eb172ded630b1c59eef9c79a6a.html /SpaceShow/leaveword/List.aspx?
uid=319211)的评论⽤户名、评论⽤户地址、评论时间、评论内容、回复次数,并将结果存储到MongoDB中。
47、
【任务描述】
任务1-1 安装mongoDB数据库
任务1-2 启动mongoDB服务端和客户端
任务1-3 使⽤配置⽂件启动mongoDB服务端和客户端
任务1-4 将mongoDB服务器作为本地服务启动
【任务要求】
1、完成实验报告并上传:把操作过程的关键步骤截图下来,每张图⽚辅以⽂字的说明,每个任务的截图张数为(3-5张)。
2、作业标题为:【第1次作业】mongoDB的安装、启动与配置
答案:
48、请完成实训任务⼀的内容,并以附件形式提交。SWF或者doc格式都可。
49、环境变量.txt
答案:
50、在Windows平台下安装mongoDB 3.4版本,并配置好环境变量
答案:
51、⼿动启动mongoDB服务端和客户端
答案:
52、使⽤配置⽂件启动mongoDB服务端和客户端
答案:
53、将mongoDB服务器作为本地服务启动
答案:
54、使⽤命令创建数据库myDB和集合collection1
答案:
55、使⽤命令查看当前所有数据库
答案:
56、使⽤命令切换到数据库testDB
答案:
57、使⽤命令显⽰当前的数据库
答案:
58、使⽤命令删除当前数据库testDB
答案:
59、使⽤命令显式创建集合students
答案:
60、使⽤命令显式创建集合teachers,要求该集合⼤⼩固定为1G,集合中最多允许1万条记录
答案:
61、使⽤命令隐式创建集合employees,该集合⾥⾯有⼀条记录【姓名:张三,年龄:25,职位:程序员,部门:研发部,⼯资:9000】
答案:
62、使⽤命令查看当前数据库当中的所有集合
答案:
63、使⽤命令删除集合employees
答案:
64、⽤insert()向students集合中添加:_id为1001,姓名为张三,年龄为20的⽂档。
答案:
65、⽤save()向students集合中添加:姓名为尼古拉斯赵四,年龄为20的⽂档。
答案:

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。