Some basic operations of MongoDB

Source: Internet
Author: User

1. List all databases>show DBS 2. Using the database>use Memo 3. List the collections of the current database>show Collections 4. Displaying data currently in Operation>db 5. List Users>show Users 6. New Database and data collection>db>show DBS If you are new, use a new database name. If it is a modification, find a database >use test2>db.createcollection ("T_test") in the result set of show DBS; >show DBS View Results 7. Inserting Data Method 1:>t={name: "Thisisname", IP: "192.168.2.2"};>db.t_test.save (t); >db.t_test.find (); Method 2:>db.t_test.insert ({name: "ThisIsName2", IP: "192.168.2.3"}); >db.t_tset.find (); 8. Finding DataFind specified field data: >db.t_test.find ({name: "ThisIsName2"}); 9. Updating Data>db.t_test.update ({name: "User3"},{$set: {IP: "192.168.2.4"}}); >db.t_test.find (); 10. Delete DataDelete Row data >db.t_test.remove ({name: "This is Name"}); >db.t_test.find (); 11. Delete a table>show collections you can see the table in this database >db.t_test.drop (); Delete succeeds returns true 12. Deleting a database>db.dropdatabase (); >show DBS

Some basic operations of MongoDB

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.