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