分类分类
2024-03-26 14:43作者:下载吧
前面说了到数据库连接操作,请参考: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" }
相关文章