MongoDB Learning Notes

Source: Internet
Author: User
Tags bulk insert install mongodb modifier

1. MongoDB Installation: install MongoDB under Linux

2, for MongoDB's own understanding:

Object-oriented, highly extensible, such as a multi-field, or save a field, storing content as a bjon string.
Manually Start MongoDB
1. Create a new MONGO folder
2. Create a new Mongodb.bat in the MONGO folder
3, enter in Mongodb.bat: Mongod--dppath. /mongo.exe (exe path)

Create a usage database: Use [databaseName] is stored in the cache, and when you do not leave it will be deleted
View all databases: Show DBS
See which documents (tables) < collections > Show colections
View all documents in the database: Show collections
View data for the specified document: DB. [Documentname].find ()
View the first data: db. [Documentname].findone ()

Insert data: DB. [documentname].insert[{...}]
BULK INSERT: Shell for loop insert
The save is different from the insert operation: when _ID is the same, insert is an error, and save is saved < updated >

Update document data: DB. [Documentname].update ({query condition},{update content})
Db. [Documentname].update ({finder},{modifier})
Insertorupdate:db. [Documentname].update ({finder},{modifier},true) performs insert when not found
Batch update: DB. [Documentname].update ({finder},{modifier},false,true) does not perform insertorupdate and performs bulk update
Delete the data in the document: DB. [Documentname].remove ({...}) Example: Db.persons.remove ({name: "Ucat"}) (the collection itself and the index are not deleted)
View index: System.indexes.find ()
Delete table: DB. [Document].drop ()
Delete database: Db.dropdatabase ()

Naming specification: Must not contain: spaces 、,、....
Cannot have the same name as the system library: Admin,local,config
Db-test legal, but not through DB. [DocumentName] obtained, changed to Db.getcollection[documentname]

MongoDB's shell built-in JavaScript engine can execute JS code directly

Mongovue (MongoDB database connection tool)

Find detailed
Db. [Documentname].find ({condition},{key specified})

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.