MongoDB 数据导入 mongoimport
2014-05-24 10:23
375 查看
1、概述
使用mongoimport命令可以把指定格式的文件导入到指定集合中。可导入JSON数据以及CSV数据。2、语法
C:\mongo\bin>mongoimport --help 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 ( <set name>/s1,s2 for sets) --port arg server port. Can also use --host hostname:port --ipv6 enable IPv6 support (disabled by default) -u [ --username ] arg username -p [ --password ] arg password --dbpath arg directly access mongod database files in the given path, instead of connecting to a mongod server - 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 -d [ --db ] arg database to use -c [ --collection ] arg collection to use (some commands) -f [ --fields ] arg comma separated 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 --upsert insert or update objects that already exist --upsertFields arg comma-separated fields for the query part of the upsert. You should make sure this is indexed --stopOnError stop importing at first error rather than continuing --jsonArray load a json array, not one item per line. Currently limited to 4MB.说明:
-h:数据库宿主机IP
-u:数据库用户名
-p:数据库密码
-d:数据库名字
-c:集合名字
-f:指明导入的列
3、示例
首先删除emp中的数据。db.emp.remove( );导入JSON格式的数据:
导入CSV格式的数据:
说明:
-type:指明要导入的文件格式。
--headerline:指明不导入第一行,csv格式的文件第一行为列名。
-file:指明要导入的文件路径。
相关文章推荐
- Mongodb数据导出命令mongoexport和导入命令mongoimport介绍
- Mongodb数据导出工具mongoexport和导入工具mongoimport介绍
- Mongodb数据导出工具mongoexport和导入工具mongoimport介绍(转)
- Mongodb数据导出工具mongoexport和导入工具mongoimport介绍
- Mongodb数据导出工具mongoexport和导入工具mongoimport使用
- Mongodb数据导出工具mongoexport和导入工具mongoimport介绍
- Mongodb数据导出工具mongoexport和导入工具mongoimport介绍
- MongoDB 数据导入 mongoimport
- Mongodb数据 导入导出数据 导出工具mongoexport和导入工具mongoimport介绍
- Mongodb数据导出工具mongoexport和导入工具mongoimport介绍
- MongoDB学习笔记4 - MongoDB数据导入实验(mongoimport)
- Mongodb数据导出工具mongoexport和导入工具mongoimport介绍
- mongodb快速入门之-----------------------------数据导入mongoimport
- Mongodb数据导出工具mongoexport和导入工具mongoimport介绍
- Mongodb数据导出工具mongoexport和导入工具mongoimport使用
- MongoDB数据导入和导出
- mongodb数据导入导出以及备份恢复
- mongodb数据导入导出以及备份恢复
- mongodb导出和导入数据
- mongodb数据导入导出