Common MongoDB operations-databases, mongodb-Databases

Source: Internet
Author: User

Common MongoDB operations-databases, mongodb-Databases

1. view all databases and run the show dbs command.

 

2. view the current database and use the command db

 

3. view all the collections in the current database, and run the show collections command or show tables command.

 

4. Create a database and use the command use database name, for example, use mydb1.

The name of the database followed by the use command. If the database exists, it is created if it does not exist. Therefore, this method is called implicit creation.
Note: After you use the command use mydb1 to create a database, the corresponding data file is not actually generated. If you exit at this time, the database will be deleted. Only after you create a collection in this database, to generate a data file.

 

5. Delete the current database and run the database. dropDatabase () command ()

 

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.