MongoDB Common Operations Summary

Source: Internet
Author: User

Operation of ====================================mgdb ======================================

0. The database is created using the (use database name), but if you do not have any other operations (such as a given list) to exit directly after the usage command, then the database executed by the use command will be purged from the buffer pool and not really created! ;

The 1.use command can not only declare the creation of the database but also can switch the database * * *;

2. Delete a database to switch to the database after you use Db.dropdatabase ();

3. Query How many databases are currently logged in to use the show DBS command;

====================================MGDB List Operation ======================================

5. Query the current database has several lists using the show Collections command;

6. Use the db.list name when deleting a list from a database. Drop ();

7. Add a list to the database (the list must have elements) when you first switch to the current database and use the Db.list name. Insert ({name: "ASD", Age: "12"});

Data manipulation in the list of ====================================mgdb ======================================

8. Insert a data in the list using the Db.list name. Insert ({name: "ASD", Age: "12"});

8.1-> If a special list is declared in the database (for example: d-d), you need to use Db.getcollection ("list name") to insert data into such a list. Text.insert ({...}); command, so be aware of the naming;

8.2-> can use insert for bulk data insertion using a for loop;

8.3-> If you name the "_id" key when inserting data to the list and produce duplicate data, using insert will give an error, and using save will change to the same data as the "_id" key;

9. The command to modify a list data is the db.list name. Update ({name: "ASD"},{$set: {name: "BBB"}});

10. Delete a list element db.list name. Remove ({"name": "GG"});

11. Remove all records using the db.list name. Remove (); When the index is not deleted * * * If the amount of data and its large size use the Db.list name. Drop (); High Efficiency * * *

MongoDB Common Operations Summary

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.