MongoDB安装
网址:https://robomongo.org/download
配置环境变量
复制路径
打开配置页面
点击新建。并将复制的路径粘贴然后点击确认
新建
创建用户,密码及权限
MongoDB实际操作
1
2.管理集合
创建数据集合
db.createCollection("teacher")
删除集合
db.teacher.drop()
查看集合记录条数
db.student.count()
查看数据空间容量,单位字节
db.student.dataSize()
集合重命名
db.student.renameCollection("stu")
添加数据
MongoDB查询操作
1.条件查询
无条件查询
db.stu.find()
有条件查询
db.student.find({name:"诸葛亮",sex:"男"})
2.表达式
MongoDB表达式必须写成JSON格式
序号 | 表达式 | 含义 |
1 | $lt | 小于 |
2 | $gt | 大于 |
3 | $lte | 小于等于 |
4 | $gte | 大于等于 |
5 | $in | 包含 |
6 | $nin | 不包含 |
7 | $ne | 不等于 |
类似于MySQL中模糊查询like