mongodb 更新多個字段 MongoDB的使用

2021-10-12 20:30:48 字數 1683 閱讀 9353

今天來學習乙個新的資料庫,叫做mongodb資料庫,我們先來了解一下mongodb資料庫的概念,再一起學習如何使用mongodb資料庫吧~

db.help() 檢視庫級別的命令db.mycoll.help() 檢視collection級別的命令sh.help() 檢視發片的命令rs.help() 檢視副本集的命令help admin 檢視管理相關的命令help connect 檢視連線到資料庫的命令help keys keys的相關命令help misc misc things to knowhelp mr 檢視mapreduce相關的命令show dbs 檢視當前的資料庫show collections 檢視資料庫中所有的collectionsshow users 當前的資料庫中有哪些使用者show profile 顯示profile資訊,顯示效能評估工具show logs 顯示日誌名資訊show log [name] 顯示指定檢視對應日誌的資訊use  進入某庫,設定某庫為當前庫db.foo.find() 列出當前collection中所有的documentdb.foo.find(  ) 列出當前collection中a = 1的documentit result of the last line evaluated; use to further iteratedbquery.shellbatchsize = x 設定顯示的item的行數exit 退出mongo shell
db.students.remove()# 刪除表db.students.drop()# 刪除當前資料庫db.dropdatabase()
比較操作:

db.students.find(}) age大於10
db.students.find(}) age大於等於20
db.students.find(}) age小於30
db.students.find(}) age小於等於40
db.students.find(}) age在[10, 20]的document
db.students.find(}) age不在[30, 40]的document
邏輯運算:

db.students.find(}, }]})
元素查詢:

如查詢存在name欄位的documentdb.students.find(})
將name為tom的這個document的age欄位的值改為20db.students.update(, })
刪除name欄位為tom的document的age為25的字段db.students.update(, }
給name欄位為tom的document增加乙個字段***且值為男db.students.update(, })
# 建立使用者db.createuser({user:"root

Oracle 多表更新多個字段

總體原則 1 更新的時候一定要加where條件,否則必然引起該字段的所有記錄更新 2 跨表更新時,set和where時,儘量減少掃瞄次數,從而提高優化 update更新例項 1 最簡單的形式 單錶更新 sql 經確認customers表中所有customer id小於1000均為 北京 1000以內...

mongodb批量更新某個字段

db.getcollection my booking find foreach function item 查詢出hospitalname是xx醫院和openid不以2開頭的所有記錄,並且更新my booking表中的paytype為2.db.getcollection my booking fi...

mybatis 實現批量更新多個字段

一條記錄update一次,效能比較差,容易造成阻塞。mysql沒有提供直接的方法來實現批量更新,但可以使用case when語法來實現這個功能。update course set name case id when 1 then name1 when 2 then name2 when 3 then...