首页 > 数据库技术 > 详细

MongoDB(三) 常用操作

时间:2018-04-15 18:37:18      阅读:208      评论:0      收藏:0      [点我收藏+]

MongoDB 常用操作

# 查看索引是否存在
> db.boundary.ensureIndex({ "geometry" : "2dsphere" } )
{
    "createdCollectionAutomatically" : false,
    "numIndexesBefore" : 2,
    "numIndexesAfter" : 2,
    "note" : "all indexes already exist",
    "ok" : 1
}

# 删除索引
> db.boundary.dropIndex({ "geometry" : "2dsphere" })
{ "nIndexesWas" : 2, "ok" : 1 }

# 查询某一字段是否存在
> db.boundary.find( { "geometry": { $exists: true } } ).count()
54

# 删除表中的某一字段
> db.boundary.update( {}, {$unset: {"geometry":""} }, {multi: true} )
WriteResult({ "nMatched" : 1971, "nUpserted" : 0, "nModified" : 54 })

# 创建索引
db.boundary.createIndex({ "geometry": "2dsphere" })

MongoDB(三) 常用操作

原文:https://www.cnblogs.com/bermaker/p/8848667.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!