zoukankan      html  css  js  c++  java
  • Mongodb常用命令

    MongoDB 常用命令

    Help #mongodb支持的命令

    Show dbs #查看所有数据库

    Use test#切换数据库

    Db#查看当前连接在哪个数据库

    Show collection#查看所有的collection

    Db.help()#当前数据库支持哪些操作

    Db.user.help()#当前数据库下的表或者表collection支持的操作

    Db.foo.find()#查找所有表内容

    Db.foo.findone()#查看最先匹配的第一条记录

    Db.foo.find({‘msg’ : ‘hello 1’}).Limit(10)#根据条件检索10条记录

    Db.mail_addr.drop()#删除collection

    db.dropDatabase()#删除当前数据库

    Db.tablename.remove({‘yy’ : 5})#删除yy=5的记录

    Db.tablename.remove()#删除所有记录

    db.createCollection(“crm_fame_daybook”) 建表

    mongod –quiet –config /etc/mongod.conf  检查配置文件

    #存储嵌套的对象

    Db.foo.save({‘name’:’ysz’,’address’:{‘city’:’beijing’,’post’:100096},’phone’:[138,139]})

    #存储数组的对象

    db.user_addr.save({‘Uid’:’yushunzhi[@sohu](/user/sohu).com’,’Al’:[‘test-1[@sohu](/user/sohu).com’,’test-2[@sohu](/user/sohu).com’]})

    #根据query条件修改,如果不存在则插入,允许修改多条记录

    db.foo.update({‘yy’:5},{‘$set’:{‘xx’:2}},upsert=true,multi=true)

  • 相关阅读:
    优化SQL Server数据库的经验总结
    #main和.main区别
    通过SQL把n条记录插入表中
    11月6日到8日参加微软Tech.ED2008大会
    NOIP2017 D2T1奶酪
    NOIP2017 D1T2时间复杂度
    NOIP2017 D2T2宝藏
    NOIP2017 D1T1小凯的疑惑
    NOIP2017 D1T3逛公园
    NOIP2017 D2T3列队
  • 原文地址:https://www.cnblogs.com/chaoe/p/7606642.html
Copyright © 2011-2022 走看看