美文网首页
MongoDB 总览

MongoDB 总览

作者: yangxg | 来源:发表于2016-09-15 20:17 被阅读0次

    先从帮助命令入手,看能做哪些事情。

        db.help()                    help on db methods
        db.mycoll.help()             help on collection methods
        sh.help()                    sharding helpers
        rs.help()                    replica set helpers
        help admin                   administrative help
        help connect                 connecting to a db help
        help keys                    key shortcuts
        help misc                    misc things to know
        help mr                      mapreduce
    
        show dbs                     show database names
        show collections             show collections in current database
        show users                   show users in current database
        show profile                 show most recent system.profile entries with time >= 1ms
        show logs                    show the accessible logger names
        show log [name]              prints out the last segment of log in memory, 'global' is default
        use <db_name>                set current database
        db.foo.find()                list objects in collection foo
        db.foo.find( { a : 1 } )     list objects in foo where a == 1
        it                           result of the last line evaluated; use to further iterate
        DBQuery.shellBatchSize = x   set default number of items to display on shell
        exit                         quit the mongo shell
    

    db.help()db.mycoll.help() 从字面意思很容易看出是数据库 (database,类似关系型数据库的库) 和里面集合 (collection,类似关系型数据库的表),这两个命令内容非常多,是一系列核心操作。

    sh.help():google 一番:

    Sharding is a type of database partitioning that separates very large databases the into smaller, faster, more easily managed parts called data shards. The word shard means a small part of a whole.

    大概是数据库体积变得非常大的时候的优化手段。

    rs.help():mongodb 官网是这样介绍的:

    A replica set in MongoDB is a group of mongod processes that maintain the same data set. Replica sets provide redundancy and high availability, and are the basis for all production deployments.

    类似 mysql 的主从数据库概念。

    help admin:一些操作文件,诊断信息的命令。

    help connect:如何连接到 mongodb。

    help keys:shell 可用的快捷键。

    help misc

    To get a list of the wrapper classes available in the mongo shell, such as BinData(), type help misc in the mongo shell

    可以通过这个命令查询数据被 BinData() 包裹之后可以执行的方法。

    help mr

    Map-reduce is a data processing paradigm for condensing large volumes of data into useful aggregated results. For map-reduce operations, MongoDB provides the mapReduce database command.

    将巨大的数据汇总成直观的结果。

    剩下的都是一些比较简单的查询命令和其它命令。

    相关文章

      网友评论

          本文标题:MongoDB 总览

          本文链接:https://www.haomeiwen.com/subject/gedbettx.html