MongoDB 常用命令
来源:互联网 发布:手机杜比音效软件 编辑:程序博客网 时间:2024/06/06 09:24
create DB
use newDBname;
create collection
db.newCollectionName.insert({m:"test"});
query by time
db.DOL_LIVE.find({t:{'$gte':'2011-01-01 09:32:42,485','$lte':'2012-01-01 09:32:42,485'}});
query by like "%str%"
db.DOL_LIVE.find({m:{'$regex':'.*str.*'}});
remove by time
db.DOL_LIVE.remove({t:{'$gte':'2011-01-01 09:32:42,485','$lte':'2012-01-01 09:32:42,485'}})
find most recent records(skip most records);
db.DOL_LIVE.find().count()
db.DOL_LIVE.find().skip(10000).limit(5)
Create a Capped Collection (To create a capped collection limited to 40 KB)
db.createCollection("mycoll", {capped:true, size:40*1024})
Convert a Collection to Capped
db.runCommand({"convertToCapped": "mycoll", size: 100*1024*1024});
check if a collection is Capped
db.myCollection.isCapped()
check stats of db
db.stats()
To reclaim deleted space, use either of the following:
--compact, which defragments deleted space. compact requires up to 2 gigabytes of extra disk space to run. Do not use compact if you are critically low on disk space.
--repairDatabase, which rebuilds the database. Both options require additional disk space to run. For details, see Recover MongoDB Data following Unexpected Shutdown.
[Warning]: repairDatabase requires enough free disk space to hold both the old and new database files while the repair is running. Be aware that repairDatabase will block all other operations and may take a long time to complete.
use newDBname;
create collection
db.newCollectionName.insert({m:"test"});
query by time
db.DOL_LIVE.find({t:{'$gte':'2011-01-01 09:32:42,485','$lte':'2012-01-01 09:32:42,485'}});
query by like "%str%"
db.DOL_LIVE.find({m:{'$regex':'.*str.*'}});
remove by time
db.DOL_LIVE.remove({t:{'$gte':'2011-01-01 09:32:42,485','$lte':'2012-01-01 09:32:42,485'}})
find most recent records(skip most records);
db.DOL_LIVE.find().count()
db.DOL_LIVE.find().skip(10000).limit(5)
Create a Capped Collection (To create a capped collection limited to 40 KB)
db.createCollection("mycoll", {capped:true, size:40*1024})
Convert a Collection to Capped
db.runCommand({"convertToCapped": "mycoll", size: 100*1024*1024});
check if a collection is Capped
db.myCollection.isCapped()
check stats of db
db.stats()
To reclaim deleted space, use either of the following:
--compact, which defragments deleted space. compact requires up to 2 gigabytes of extra disk space to run. Do not use compact if you are critically low on disk space.
--repairDatabase, which rebuilds the database. Both options require additional disk space to run. For details, see Recover MongoDB Data following Unexpected Shutdown.
[Warning]: repairDatabase requires enough free disk space to hold both the old and new database files while the repair is running. Be aware that repairDatabase will block all other operations and may take a long time to complete.
阅读全文
0 0
- mongodb常用命令
- mongodb常用命令
- MongoDB常用命令
- MongoDB常用命令
- MongoDB常用命令
- Mongodb常用命令
- mongodb常用命令
- mongodb常用命令
- mongodb常用命令
- mongodb常用命令
- mongodb 常用命令
- mongodb常用命令
- MongoDB 常用命令
- MongoDB 常用命令
- mongodb 常用命令
- mongodb常用命令
- mongodb常用命令
- MongoDB 常用命令
- 将Eclipse项目自动部署到Tomcat的webapps目录下
- PCSCHEMATIC ELAUTOMATION.V19.0.1.69中文正式单机版
- 关于vs2005、vs2008和vs2010项目互转的总结
- 数据交互的加密算法
- 创建window service
- MongoDB 常用命令
- EXCEL 操作详解精品
- C语言:问题求解方法-穷举
- 备份和恢复MongoDB
- PHP魔术方法之构造方法__construct与析构方法__destruct
- 单点登录SSO的实现原理
- VIM命令
- Python读取XML
- c语言创建写入和读取TXT文件数据