MongoDB Learning Notes-database operations

Source: Internet
Author: User

Use Use the database name to create the database and return the database statement formatIf it already exists: usedatabase_name

>use mynewdb

Switched to DB mynewdb

Use ? db name to check the currently used database

> DB

Mynewdb

using Commands ? show dbs? to check the list of databases.

> Show DBS

Gnymongo 0.078GB

Gnyworkflowdemo 0.078GB

Loginfo 0.078GB

......

the database you just created mynewdb? does not appear in the list. In order for the database to appear, at least one document should be inserted

Db.test.insert ({"X": 1})

If you want to delete a new database ? mynewdb, use this as follows ? Dropdatabase ()? Method

>use mynewdb

Switched to DB mynewdb

> Db.dropdatabase ()

relational database and MongoDB The comparison of the database in some terms

show dbs

TD style= "PADDING-TOP:8PX; padding-left:8px; padding-bottom:8px; padding-right:8px; Border-top:none; Border-bottom:solid #dddddd 0.75pt ">

relational database (MySQL)

MongoDB

remarks

create database mynewdb

use mynewdb

CREATE database

use mynewdb

use mynewdb

Toggle and use database

select database ()

db

Check the currently used database

show databases

Check database list

Drop Database mynewdb

Db.dropdatabase ()

Check Database list

MongoDB Learning Notes-database operations

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.