<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    隨筆-86  評論-33  文章-0  trackbacks-0

    Import Export Tools

    These tool just work with the raw data (the documents in the collection); they do not save, or load, the metadata like the defined indexes or (capped) collection properties. You will need to (re)create those yourself in a separate step, before loading that data. Vote here to change this.

    mongoimport

    This utility takes a single file that contains 1 JSON/CSV/TSV string per line and inserts it. You have to specify a database and a collection.

    options:
                --help                  produce help message
                -v [ --verbose ]        be more verbose (include multiple times for more
                			    verbosity e.g. -vvvvv)
                -h [ --host ] arg       mongo host to connect to ("left,right" for pairs)
                -d [ --db ] arg         database to use
                -c [ --collection ] arg collection to use (some commands)
                -u [ --username ] arg   username
                -p [ --password ] arg   password
                --dbpath arg            directly access mongod data files in the given path,
                			    instead of connecting to a mongod instance - needs to
                			    lock the data directory, so cannot be used if a
                			    mongod is currently accessing the same path
                --directoryperdb        if dbpath specified, each db is in a separate
                directory
                -f [ --fields ] arg     comma seperated list of field names e.g. -f name,age
                --fieldFile arg         file with fields names - 1 per line
                --ignoreBlanks          if given, empty fields in csv and tsv will be ignored
                --type arg              type of file to import.  default: json (json,csv,tsv)
                --file arg              file to import from; if not specified stdin is used
                --drop                  drop collection first
                --headerline            CSV,TSV only - use first line as headers
                

    mongoexport

    This utility takes a collection and exports to either JSON or CSV. You can specify a filter for the query, or a list of fields to output.

    Neither JSON nor TSV/CSV can represent all data types. Please be careful not to lose or change data (types) when using this. For full fidelity please use mongodump.

    If you want to output CSV, you have to specify the fields in the order you want them.

    Example

    options:
                --help                  produce help message
                -v [ --verbose ]        be more verbose (include multiple times for more
                			    verbosity e.g. -vvvvv)
                -h [ --host ] arg       mongo host to connect to ("left,right" for pairs)
                -d [ --db ] arg         database to use
                -c [ --collection ] arg collection to use (some commands)
                -u [ --username ] arg   username
                -p [ --password ] arg   password
                --dbpath arg            directly access mongod data files in the given path,
                			    instead of connecting to a mongod instance - needs to
                			    lock the data directory, so cannot be used if a
                			    mongod is currently accessing the same path
                --directoryperdb        if dbpath specified, each db is in a separate
                directory
                -q [ --query ] arg      query filter, as a JSON string
                -f [ --fields ] arg     comma seperated list of field names e.g. -f name,age
                --csv                   export to csv instead of json
                -o [ --out ] arg        output file; if not specified, stdout is used
                

    mongodump

    This takes a database and outputs it in a binary representation. This is mostly used for doing hot backups of a database.

    If you're using sharding and try to migrate data this way, this will dump shard configuration information and overwrite configurations upon restore.
    options:
                --help                   produce help message
                -v [ --verbose ]         be more verbose (include multiple times for more
                			     verbosity e.g. -vvvvv)
                -h [ --host ] arg        mongo host to connect to ("left,right" for pairs)
                -d [ --db ] arg          database to use
                -c [ --collection ] arg  collection to use (some commands)
                -u [ --username ] arg    username
                -p [ --password ] arg    password
                --dbpath arg             directly access mongod data files in the given path,
                			     instead of connecting to a mongod instance - needs
                			     to lock the data directory, so cannot be used if a
                				     mongod is currently accessing the same path
                --directoryperdb         if dbpath specified, each db is in a separate
                directory
                -o [ --out ] arg (=dump) output directory
                

    Example: Dumping Everything

    To dump all of the collections in all of the databases, run mongodump with just the --host:

    $ ./mongodump --host prod.example.com
                connected to: prod.example.com
                all dbs
                DATABASE: log    to   dump/log
                log.errors to dump/log/errors.bson
                713 objects
                log.analytics to dump/log/analytics.bson
                234810 objects
                DATABASE: blog    to    dump/blog
                blog.posts to dump/log/blog.posts.bson
                59 objects
                DATABASE: admin    to    dump/admin
                

    You'll then have a folder called "dump" in your current directory.

    If you're running mongod locally on the default port, you can just do:

    $ ./mongodump
                

    Example: Dumping a Single Collection

    If we just want to dump a single collection, we can specify it and get a single .bson file.

    $ ./mongodump --db blog --collection posts
                connected to: 127.0.0.1
                DATABASE: blog        to     dump/blog
                blog.posts to dump/blog/posts.bson
                59 objects
                

    mongorestore

    This takes the output from mongodump and restores it.

    usage: ./mongorestore [options] [directory or filename to restore from]
                options:
                --help                  produce help message
                -v [ --verbose ]        be more verbose (include multiple times for more
                			    verbosity e.g. -vvvvv)
                -h [ --host ] arg       mongo host to connect to ("left,right" for pairs)
                -d [ --db ] arg         database to use
                -c [ --collection ] arg collection to use (some commands)
                -u [ --username ] arg   username
                -p [ --password ] arg   password
                --dbpath arg            directly access mongod data files in the given path,
                				    instead of connecting to a mongod instance - needs to
                				    lock the data directory, so cannot be used if a
                			    mongod is currently accessing the same path
                --directoryperdb        if dbpath specified, each db is in a separate
                directory
                --drop                  drop each collection before import
                --objcheck              validate object before inserting
    posted on 2010-07-05 17:52 Derek.Guo 閱讀(1195) 評論(0)  編輯  收藏 所屬分類: NoSqlDB

    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    MSN:envoydada@hotmail.com QQ:34935442
    主站蜘蛛池模板: 亚洲成a人片在线观看中文动漫| 全免费A级毛片免费看网站| 亚洲午夜爱爱香蕉片| 久久久久久亚洲av无码蜜芽| 最近免费中文字幕视频高清在线看| 亚洲福利视频一区二区三区| 无码国产精品一区二区免费3p| 国产l精品国产亚洲区在线观看| 国产一级a毛一级a看免费人娇| 久久亚洲精品无码观看不卡| 黄床大片免费30分钟国产精品| 亚洲人成无码www久久久| 中美日韩在线网免费毛片视频| 亚洲国产天堂久久综合| igao激情在线视频免费| 亚洲中文字幕成人在线| 最新亚洲成av人免费看| 亚洲AV综合色区无码一区爱AV| 亚洲电影免费在线观看| 亚洲制服丝袜精品久久| 成年丰满熟妇午夜免费视频| 亚洲av永久无码| 伊人婷婷综合缴情亚洲五月| 久久久精品视频免费观看 | 精品国产亚洲第一区二区三区 | 一个人看www免费高清字幕| 在线a亚洲v天堂网2019无码| 国产精品99精品久久免费| 亚洲国产综合自在线另类| 欧洲美熟女乱又伦免费视频| 一区二区免费在线观看| 亚洲av无码不卡| 我要看免费的毛片| 午夜不卡AV免费| 久久久婷婷五月亚洲97号色| 成年女人毛片免费播放人| 最近中文字幕免费大全| 亚洲五月综合网色九月色| 亚洲国产成人久久综合区| 四虎影视成人永久免费观看视频| 亚洲中文字幕一二三四区苍井空|