Saber2pr's Blog

MongodbAdditionDeletionAndModification

Mongodb storage structure: database > collection > document

Interactive

  1. Turn on interactive
mongo

two。 List the databases that exist

show dbs
  1. Create a database
use saber2pr
  1. Create a collection in the database
db.createCollection("qwq")
  1. List the collections that exist in the database
show collections
  1. Insert a document into the collection
db.qwq.insert({name: "saber"})
  1. Find the specified document in the collection
db.qwq.find({name: "saber"})
  1. Find all documents in the collection
db.qwq.find()
  1. Delete the specified document in the collection
db.qwq.remove({name: "saber"})
  1. Delete all documents in the collection
db.qwq.remove({})
  1. Delete the specified collection in the database
db.qwq.drop()

twelve。 Delete the specified database

use saber2pr

db.dropDatabase()