-
在mongodb 中 update 默認只是更新查找到的第一條數(shù)據(jù)
那么怎么一次更新多條呢?
db.test.update({x:1},{$set{x:2}},false,true)
查看全部 -
db.test.update({name:'hhp'},{name:?'ls'}) db.test.update({z:100},{$set:{y:99}};
mongo 可以更新數(shù)據(jù),還可以更新不存在的數(shù)據(jù)
更新不存在的數(shù)據(jù)時自動創(chuàng)建
db.test.update({z:100},{z:999},true)
此時因為不存在{z:100} 的項,所以找不到,也就無法更新,所以后面加了一個true就可以創(chuàng)建這個{z:999}的數(shù)據(jù)了。
查看全部 -
for(i=3;i<100;i++)db.test.insert({name:i})
db 可以使用js語法插入數(shù)據(jù)。
查看全部 -
寫入? ?db.(表名).instert({})
查看全部 -
在使用use之前我們不需要對數(shù)據(jù)庫進行額外的創(chuàng)建,mongod會在適當?shù)臅r候自己創(chuàng)建。
查看全部 -
db.shutdownServer() 切斷服務
db.dropDatabase() 關閉數(shù)據(jù)庫
use imooc自動創(chuàng)建數(shù)據(jù)庫并切換數(shù)據(jù)庫
show dbs
show tables
show collections
查看全部 -
./bin/mongo 127.0.0.1:12701/test 命令
./log日志
./data數(shù)據(jù)
./conf配置文件
查看全部 -
db.collection.getIndexes()查詢索引
db.collection.ensureIndex({x:1})創(chuàng)建索引
對于常用查詢的索引創(chuàng)建是非常必要的,會犧牲插入效率
查看全部 -
db.collection.insert({x:1})插入數(shù)據(jù)
for(i=3;i<100;i++)db.collection.insert({x:i})可以使用jison語法循環(huán)插入數(shù)據(jù)
db.collection.update({x:1},{$set:{x:2}},false,true)更新說明:條件、內容、true不滿足插入、全部符合內容更新
db.collection.remove({x:2})必須有參數(shù),刪除數(shù)據(jù)
db.collection.drop()刪除數(shù)據(jù)表
db.collection.find({x:1})查詢數(shù)據(jù)
查看全部 -
? 創(chuàng)建用戶,userAdmin可以對用戶進行管理,read讀取數(shù)據(jù)
查看全部 -
MongoDB角色
查看全部 -
開啟權限認證
查看全部 -
Mongodb資料網(wǎng)站查看全部
-
MongoDB完全的索引支持:
單鍵、多鍵;
數(shù)組;
全文;
地理位置;
查看全部 -
NoSql數(shù)據(jù)庫對比
查看全部
舉報