迷茫2017-04-24 09:14:28
There is no direct method, only copy and then delete:
db.copyDatabase('old_name', 'new_name');
use old_name
db.dropDatabase();
==2017.4.4 Update==
is still an indirect solution, but WiredTiger
there is a more convenient solution for the storage engine: db.renameCollection.
use admin;
db.runCommand({renameCollection: "test.test", to: "test1.test"});
When you move all collections to a new library, it is equivalent to renaming the entire library. This will be much faster than copyDatabase
.