Mongodb安装和实用命令
> db.mytestcoll.insert({key1:"testkey1",key2:"testkey2",key3:"testkey3"})在聚集集合中插入一个文档
WriteResult({ "nInserted" : 1 })
> db.mytestcoll.insert({key1:"testkey1",key3:"testkey3_1",key2:"testkey2_1"})
WriteResult({ "nInserted" : 1 })
> db.mytestcoll.find()
{ "_id" : ObjectId("54b4b28860a9f83fc16e738d"), "key1" : "testkey1", "key2" : "testkey2", "key3" : "testkey3" }
{ "_id" : ObjectId("54b4b32c60a9f83fc16e738e"), "key1" : "testkey1", "key3" : "testkey3_1", "key2" : "testkey2_1" }
> db.mytestcoll.save({key1:"mytestkey1",key2:"testkey2"})也能保存一个文档到聚集集合 WriteResult({ "nInserted" : 1 })
> DBQuery.shellBatchSize= 1设置了每页显示几条记录,现在设置为1条
1
> db.mytestcoll.find()
{ "_id" : ObjectId("54b4b28860a9f83fc16e738d"), "key1" : "testkey1", "key2" : "t
estkey2", "key3" : "testkey3" }
Type "it" for more
> it 显示下一页的记录
{ "_id" : ObjectId("54b4b32c60a9f83fc16e738e"), "key1" : "testkey1", "key3" : "t
estkey3_1", "key2" : "testkey2_1" }
> db.mytestcoll.find({"key2":"testkey2_1"}) 以键值形式获取查询到的结果 相当于select * from mytestcollwhere key2= “testkey2_1”;
{ "_id" : ObjectId("54b4b32c60a9f83fc16e738e"), "key1" : "testkey1", "key3" : "t
estkey3_1", "key2" : "testkey2_1" }
> db.mytestcoll.find({"key2": {$lt: 22}})查找key2<22的值,相当于select * from mytestcoll where key2<22;
> db.mytestcoll.find({"key2": {$lte: 22}})查找key2<=22的值,相当于select * from mytestcoll where key2<=22;
> db.mytestcoll.find({"key2": {$gt: 22}})查找key2>22的值,相当于select * from mytestcoll where key2>22;
> db.mytestcoll.find({"key2": {$gte: 22}})查找key2>=22的值,相当于select * from mytestcoll where key2>=22;
> db.mytestcoll.find({"key2": {$gt:11,$lte:22}})查找22>=key2>11的值
> db.mytestcoll.find({key2:/test/})等价于select * from mytestcoll where key2 like %test% { "_id" : ObjectId("54b4b28860a9f83fc16e738d"), "key1" : "testkey1", "key2" : "t
estkey2", "key3" : "testkey3" }
{ "_id" : ObjectId("54b4b32c60a9f83fc16e738e"), "key1" : "testkey1", "key3" : "t
estkey3_1", "key2" : "testkey2_1" }
> db.mytestcoll.find({key2:/^test/})等价于select * from mytestcoll where key2 like test% 查找key2中,以”test”开头的文档
{ "_id" : ObjectId("54b4b28860a9f83fc16e738d"), "key1" : "testkey1", "key2" : "t
estkey2", "key3" : "testkey3" }
{ "_id" : ObjectId("54b4b32c60a9f83fc16e738e"), "key1" : "testkey1", "key3" : "t
windows下安装mongodb和简单使用mongodb命令_IT/计算机_专业资料。windows 下安装 mongodb 和简单使用 mongodb 命令 windows 下安装 mongodb 和简单使用 mongodb 命令 ...
windows下mongodb常用命令 进入mongodb的安装目录bin >mongo.exe 连接数据库,默认连接test库 >use XXX 切换到XXX库 === 三、基本语法 Mongo语法 db.AddUser(user...
mongoDB常用命令 3页 1财富值 MongoDB入门&常用命令 3页 1财富值 常用命令 ...安装及使用: 首先在 Ubuntu 上安装 MongoDB: 1. 解压文件. $ tar -xvf ...
安装: 官方网站http://www.mongodb.org/downloads mkdir c:\data\db xcopy d:\mongodb-win32-1.8.1 c:\ c:\mongodb-win32-1.8.1\bin>mongod --...
mongodb篇一_mongodb基本命令_计算机软件及应用_IT/计算机_专业资料。Mongodb登录...format的使用 (0) (0) (0) IDE工具之篇一: Intellij Idea 安装插件方法 ...
MongoDB安装和使用全过程_计算机软件及应用_IT/计算机_专业资料。windows 7环境下...然后运行下面的命令: mongod -port 27017 -dbpath C:\mongodb\data\db -...
mongodb常用命令集合_计算机软件及应用_IT/计算机_专业资料。介绍mongodb的常用命令集合。还有跟mysql的对应,方便理解今日推荐 78份文档 不...
MongoDB 命令帮助系统 在安装 MongoDB 后,启动服务器进程(mongod) ,可以通过在...有关数据库和集合管理的相关命令,是最基础和最常用的,如集合查询、索引操作等...
安装 MongoDB 的 windows 服务的方法为是在 MongoDB 安装目录下创建 logs 目录,然后 在 CMD 命令行输入 E:/mongodb/bin>mongod --logpath D:/mongodb/logs/...
mongoDB在windows下的安装配置_计算机软件及应用_IT/计算机_专业资料。在windows ...mongodb dbpath 使用 dos 命令进入 使用 dos 命令进入 D:\Program Files\mong...
热门文档