MongoDB Learning Notes < a >

Source: Internet
Author: User

Today I learned the basic operation of the shell, as follows:

1. Create a database Foobar

Use Foobar

2. Add a collection to the specified database and add a record

Db.person.insert ({"Name": "ABC"})

3. View all the Databases

Show DBS

4. Querying all documents in the database

Show collections

5. Querying data for a specified document

Db.person.find ()

If you query the data for the first bar, use Db.person.findOne ()

6. Updating document data

Db.perosn.update ({"Name": "abc"},{$set: {"name": "Abc123"}}) The entry statement means finding a document with name ABC and setting its name to abc123

7. Delete document data

Db.person.remove ({"Name": "ABC"})

8. Deleting a collection from a database

Db.person.drop ()

9. Deleting a database

Db.dropdatabase ()



MongoDB Learning Notes < a >

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.