First knowledge of MongoDB

Source: Internet
Author: User

1. Very popular NoSQL database (based on Bson format, JSON extension)

2. Install, download (default port 27017)

Start Mongod--dbpath/data/db

Server-side Mongod start after the default is the listening amount of 27017 of the port, Customer service Terminal program MONGO connection server MONGO 127.0.0.1:27017--> connection success

3. Create a Database

Use dbname; (at this point, there is no real database creation, but in the preprocessing cache pool, only the actual data is added to create the data file)

4. Add a record to the corresponding database

Db. The name of the collection (equivalent to the table name in MySQL). Insert ({name: ' Ty '})

5. View all the Databases

Show DBS

6. Display all collections of documents in the corresponding database (equivalent to all tables in the MySQL database)

Show collections

7. Querying data for a specified document

Query all: DB. The name of the collection. Find () Query the first: DB. The name of the collection. FindOne ()

8 Updating document data

Db. The name of the collection. Update ({The original data)},{$set: {New Data}})

9. Delete data from a document

DB. Name in the collection. Remove ({finder})

10 deleting a collection from a database

Db. The name of the collection. Drop ()

11 Deleting a database

Db.dropdatabase ()

First knowledge 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.