時間:2024-03-26 14:43作者:下載吧人氣:26
前面說了到數(shù)據(jù)庫連接操作,請參考:mongodb 添加用戶及權(quán)限設(shè)置詳解
對數(shù)據(jù)庫的操作:請參考:mongodb 數(shù)據(jù)庫操作詳解–創(chuàng)建,切換,刪除
下面說一下,數(shù)據(jù)庫表的插入操作
1,命令行下的insert操作
> use test; #切換到test數(shù)據(jù)庫 switched to db test > document=({"title" : "linux命令", "auther" : "tank" }); #定義了一個變量 { "title" : "linux命令", "auther" : "tank" } > db.test.insert(document); #插入變量 > db.test.find(); #查看插入的數(shù)據(jù) { "_id" : ObjectId("53c8fc1cf062ac30ee8b9d2d"), "title" : "linux命令", "auther" : "tank" } > db.test.insert({"title" : "51yip", "auther" : "tank" }); #直接插入數(shù)據(jù) > db.test.find(); #查看 { "_id" : ObjectId("53c8fc1cf062ac30ee8b9d2d"), "title" : "linux命令", "auther" : "tank" } { "_id" : ObjectId("53c8f6fff062ac30ee8b9d2e"), "title" : "51yip", "auther" : "tank" }
網(wǎng)友評論