MongoDB Database Advanced---Additions and deletions to search and change ...

Source: Internet
Author: User
Tags install mongodb

In the previous article, I've covered the basics of what MongoDB is and how to install MongoDB under Windows. So this advanced blog will mainly introduce the following how the basic operation of the database---additions and deletions to check and change.

 

Database related

Show all databases :

Show DBS

Where both admin and local are databases that exist by default.

To view the current database :

Db

That is, the test database is currently the default, but why not when show DBS? This is because there is no data in the test database, so it is not displayed, and the insert data is described later, and is displayed when the data is inserted.

To Create a database :

Use < database name >

It is worth noting that the use of the database if it does not exist on the creation, if there is a switch!

To Delete a database :

Db.dropdatabase ()

This command deletes the current database.

Document related && collection related

To delete a collection :

db.< collection name >.drop ()

This deletes a specified collection under the current database.

Insert Document :

db.< Collection name >.insert (document)

If the specified collection is not present, it will be created, and if present, the document will be appended later.

It is important to note that: Enter first ({then the carriage return can be more than one line.)

Inserting a document you can also save the document to a variable, and then insert the variable.

To view a collection :

db.< collection name >.find ()

MongoDB Database Advanced---Additions and deletions to search and change ...

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.