-
過期索引限制查看全部
-
在一段時間后會過期的索引 在索引過期后,相應(yīng)的數(shù)據(jù)會被刪除 適合存儲在一段時間之后會失效的數(shù)據(jù),比如用戶的登錄信息、存儲的日志等。 >db.imooc_2.ensureIndex({time:1},{expireAfterSeconds:10}) #創(chuàng)建過期索引,time-字段,expireAfterSeconds在多少秒后過期,單位:秒查看全部
-
db.local_collection.update({y:100},{y:999},true) //如果查找的數(shù)據(jù)不存在則將之寫入查看全部
-
mongoDB:update方法有四個參數(shù) 第一個參數(shù):查找數(shù)據(jù)的條件,如{c:1} 表示查找c為1的數(shù)據(jù) 第二個參數(shù):要更新的數(shù)據(jù),如{c:2} 跟新符合條件的數(shù)據(jù)c為2,默認只更新第一個符合條件的數(shù)據(jù)。 第三個參數(shù):boolean類型,更新數(shù)據(jù)不存在時是否創(chuàng)建一條數(shù)據(jù),默認為false,設(shè)置為true時,自動創(chuàng)建數(shù)據(jù)。 第四個參數(shù):boolean類型,跟新數(shù)據(jù)時是否更新所有符合條件的數(shù)據(jù),默認為false,只跟新一條符合條件的數(shù)據(jù),設(shè)置為true時,更新所有符合條件的數(shù)據(jù)。 如db.collection.update({c:1},{$set{c:2}},false,true)查看全部
-
mongoDB基本概念格架查看全部
-
mongoDB的概念查看全部
-
數(shù)據(jù)更新 db.imooc_collection.update({x:1}, {x: 999}) 更新部分內(nèi)容需要使用$set操作符 db.imooc_collection.updata({x:1}, {$set: {y: 99}}) update 第三個參數(shù)表明,如果更新的數(shù)據(jù)不存在,則自動創(chuàng)建并更新內(nèi)容,默認為false db.imooc_collection.updata({x:1}, {y: 99}, true) updata 第四個參數(shù),需要更新多條數(shù)據(jù),默認只更新找到的第一條數(shù)據(jù), 若設(shè)置為true 則全部更新 db.imooc_collection.updata({x:1}, {$set: {x: 99}}, false, true) 數(shù)據(jù)刪除 db.imooc_collection.remove({x: 1}) // remove 與 update 不同,會默認刪除所有查找到的數(shù)據(jù)。 刪除某張表 db.imooc_collection.drop() 查看全部表 db.tables() 查看集合索引情況 db.imooc_collection.getIndexes() 創(chuàng)建索引(比較消耗性能,會影響寫入效率) db.imooc_collection.ensureIndex({x: 1}) 正向排序 x: 1 負向排序 x: -1查看全部
-
./bin/mongo 127.0.0.1:12345 // 鏈接數(shù)據(jù)庫 show dbs // 查看已存在的數(shù)據(jù)列表 use imooc // 使用數(shù)據(jù)庫 db.dropDatabase() // 刪除數(shù)據(jù)庫 show collections // 查看數(shù)據(jù)庫中創(chuàng)建的表 db.imooc_collection.find() // 數(shù)據(jù)查詢 // {'_id': 'dasdasdas', 'x': 1} _id 可以被修改,但是不能重復 db.imooc_collection.find().count() // 返回數(shù)量 mongo使用一個不存在的數(shù)據(jù)庫時,會自動創(chuàng)建。 mongo中對一張表稱為一個集合 寫入數(shù)據(jù) db.imooc_collection.insert({x: 1}) 讀取數(shù)據(jù) db.imooc_collection.find().skip(3).limit(2).sort({x: 1}) // skip 跳過前3條,limit 獲取的條數(shù) sort 對返回結(jié)果排序查看全部
-
LAMP : linux+apache+mysql+PHP查看全部
-
111查看全部
-
MongoDB的概念 MongoDB mongo 索引 集合 復制集 分片 數(shù)據(jù)均衡查看全部
-
搭建簡單的mongodb服務(wù)器查看全部
-
mongodb幾個重要的網(wǎng)站查看全部
-
為什么是mongodb查看全部
-
關(guān)閉數(shù)據(jù)庫查看全部
舉報
0/150
提交
取消