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
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 | TD style= "PADDING-TOP:8PX; padding-left:8px; padding-bottom:8px; padding-right:8px; Border-top:none; Border-bottom:solid #dddddd 0.75pt ">
Check database list |
Drop Database mynewdb |
Db.dropdatabase () |
Check Database list |
MongoDB Learning Notes-database operations