Given below are the examples of MongoDB Import: Example #1 We have maintained insertion order flag to insert the documents as per the insertion order in MongoDB. The bulk order insertion data is possible by using the mongoimport command in MongoDB. Document will be sequentially insert into the collection as they will appeared from the input file. We have used following options with mongoimport command in MongoDB at the time of importing data into the collection.įrom MongoDB version 4.2 we have insert the document from the json file will be inserted in order which they will appeared into the file. In newer version of MongoDB we have used extended json format data file to import document into the collection from the file. We have used extended json format data to import data into the collection from json file. We need to define database name, username, port number, password of user, and import file name at the time of importing data from file into the collection. Replica set name: While importing data from file we have to define replica set name while importing data into the collection.We can import the data from CSV, TSV and JSON file in MongoDB. File name: This parameter is defined as name of file from which we are importing data into the collection.Authentication database: We need to define authentication database while importing data from the file.Collection name: This is defined as name of collection from which we are importing data from the file in MongoDB.Database name: This is defined as name of database from which collection we are importing data from the file.of database server which we have used while importing data from the file. Host name: This is defined as host name of database server which we have used while importing data from the file.User password: This is defined as password of user which we have used while importing data from the file.User name: This is defined as username which we have used while importing data from the file.Uri: This is defined as connection URL which we have used while importing data from file in MongoDB.Mongoimport: This command is used to load the data into collection by using the CSV, TSV and json files.Mongoimport -host (host name) -u (name of user) -p (password of user) -authenticationDatabase (admin database used for authentication) -db (Name of database) -collection (name of collection) -drop -file /name_of_file (Name of file which was we have used to import into collection)īelow is the parameter description syntax of MongoDB Import:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
January 2023
Categories |