1. 重命名collection
db.runCommand({
"renameCollection":
"namespace.a",
"to":
"namespace.b"});
要在admin下操做
2. 删除记录不释放磁盘空间
见 http://www.mongodb.org/display/DOCS/Excessive+Disk+Space
Deleted Space
MongoDB maintains deleted lists of space within the datafiles when objects or collections are deleted. This space is reused but never freed to the operating system.
To compact this space, run
db.repairDatabase() from the mongo shell
|
this operation will block and is slow. |
When testing and investigating the size of datafiles, if your data is just test data, use
db.dropDatabase() to clear all datafiles and start fresh.
同时针对想释放空间的用户能够看如下2篇文章的讨论
MongoDB data remove - reclaim diskspace
http://stackoverflow.com/questions/5518581/mongodb-data-remove-reclaim-diskspace