mongoDB使用方法
来源:互联网 发布:linux telnet连接失败 编辑:程序博客网 时间:2024/04/29 19:52
进入数据库:use 数据库
创建集合(表):db.createCollection("mycollection")-----------------------------------------------------------create table mycollection(...)
插入数据:db.mycollection.insert({name:"xxx",sex:1,age:22.........})-----------------------------------insert mycollection value("xxx")
查询所有:db.mycollection.find()--------------------------------------------------------------------------------select * from mycollection
条件查询:db.mycollection.find({"name":"xxx"})-------------------------------------------------------------select * from mycollection where name="xxx"
and条件查询:db.mycollection.find({"name":"xxx","sex":1})------注:条件之间用逗号隔开---------select * from mycollection where name="xxx" and sex=1
or条件查询:db.mycollection.find({$or:["name":"xxx"},{"sex":1]})------注意括号和$or关键字-----select * from mycollection where name="xxx" or sex=1
in查询:db.mycollection.find({"name":{$in:["xxx","xx"]}})------注意括号和$in关键字----------------select * from mycollection where name in("xxx","xx")
notin查询:db.mycollection.find({"name":{$nin:["xxx","xx"]}})------注意括号和$nin关键字---------select * from mycollection where name notin("xxx","xx")
order by查询:db.mycollection.find().sort({key:-1})------sort方法-1倒叙1升序------------------------select * from mycollection order by id desc
求平均值:.db.mycollection.aggregate([{$group:{_id:"$id","avg":{$avg:"$age"}}}])---------------------select avg(age) from mycollection group by id
求数量:.db.mycollection.aggregate([{$group:{_id:"$id","sum":{$sum:"$age"}}}])---------------------select count(*) from mycollection group by id
修改数据: db..mycollection.update({"name":"xxx"},{$set:{"name":"xx"}})--------------------------------update mycollection set name='xx' where name="xxx"
删除数据:db.mycollection.remove({"name":"xxx"}) -------------------------------------------------------delete mycollection where name="xxx"
- mongoDB使用方法
- Python搭配MongoDB使用方法
- mongodb使用方法(1)
- Python搭配MongoDB使用方法
- mongodb的使用方法
- mongodb的使用方法
- JMeter MongoDB script使用方法
- MongoDB的使用方法
- mongodb 的简单使用方法
- JMeter MongoDB script使用方法
- mongodb的安装和使用方法
- mongodb驱动的正确使用方法
- MongoDB工具mongoexport的使用方法
- 一些MongoDB集群维护使用方法
- yii框架:MongoDB 插件 YiiMongoDbSuite 使用方法
- MongoDB的地理位置搜索GeoSearch使用方法探索
- mongodb和spring集成中MongoTemplate的总结是使用方法
- mongodb和spring集成中MongoTemplate的总结是使用方法
- 设计模式(4)-单例模式
- 图像有用区域_撞墙法
- [2015-12-29]position详解
- 支付宝被骗怎么办?
- 吝啬的国度_数组存储
- mongoDB使用方法
- 值得推荐的C/C++框架和库
- 吝啬的国度_链式前向星
- 解决mysql服务无法启动问题
- 吝啬的国度_链表_数组存储
- 关于softmax损失函数的推导
- 吝啬的国度_链表
- [2016-05-06]CSS之float详解
- 连通问题