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