時(shí)間:2024-03-26 14:43作者:下載吧人氣:29
前面說(shuō)了到數(shù)據(jù)庫(kù)連接操作,請(qǐng)參考:mongodb 添加用戶及權(quán)限設(shè)置詳解
對(duì)數(shù)據(jù)庫(kù)的操作:請(qǐng)參考:mongodb 數(shù)據(jù)庫(kù)操作詳解–創(chuàng)建,切換,刪除
下面說(shuō)一下,數(shù)據(jù)庫(kù)表的插入操作
1,命令行下的insert操作
> use test; #切換到test數(shù)據(jù)庫(kù) switched to db test > document=({"title" : "linux命令", "auther" : "tank" }); #定義了一個(gè)變量 { "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)友評(píng)論