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