Increase:
Db:
Use db_name//If there is a switch
Tabale:
There is no direct command to automatically generate when inserting a document
File
Db.table_name.insert ({' Test ': ' OK '})
Field:
Db.table_name.update ({' Test ': {$exists: true}},{$set: {' test2 ': ' Yes '}},{multi:true})//Insert ' test2 ' field into all documents containing ' test ' field
Db.table_name.update ({' Test ': {$exists: true}},{$set: {' test2 ': ' Yes '}})//Find the first document containing the ' Test ' field insert ' test2 ' field
Db.table_name.update ({' Test ': ' OK '},{$set: {' test2 ': ' Yes '}},{multi:true})//Insert ' test2 ' field into all documents containing ' test ': ' OK ' key-value pairs
By deleting:
Db:
Db.dropdatabase ()//delete current database
Table
Db.table_name.drop ()
File
Db.table_name.remove ({' Test ': {$exists: True}},{justone:true})//delete the first one found
Db.table_name.remove ({' Test ': {$exists: true}})//delete all
Field:
Db.table_name.update ({//Search condition},{$unset: {' Test ': '}},{multi:true} ')//delete all fields that meet {condition}
Check:
Db:
Show DBS
Table
Show tables
File
Db.table_name.find ({//Search condition}). Pretty ()//pretty () formatted display
Field:
No
Change:
Db:
Use Db_name
Table
No
File
Db.table_name.update ({' Test ': {$exists: true}},{' test2 ': ' Yes '},{multi:true})//Replace all document contents containing test with {' test2 ': ' Yes '}// The ' _id ' value does not change
Field:
Db.table_name.update ({' Test ': {$exists: true}},{$set: {' Test ': ' Yes '}},{multi:true})//To the ' Test ' field value for all documents containing ' test ' field ' Yes '
MongoDB Common Operations--command line