mongodb 怎麼合併多個 database
PHP中文网
PHP中文网 2017-06-21 10:11:34
0
1
1004

現在一個實例裡有 DBA, DBB, DBC, NewDB,如何把ABC匯入到NewDB?
結構是一樣的,試過For InsertInsertMany,但是資料有接近500W,插了沒幾條就不工作了。而且效率太低。
請問有什麼高效率的辦法嗎?

PHP中文网
PHP中文网

认证0级讲师

全部回覆(1)
洪涛

如果是複製集的話倒是有辦法,不是十分直觀不過我們有renameCollection Command:
注意:務必讀完上面的連結再動手。

{ renameCollection: "<source_namespace>", to: "<target_namespace>", dropTarget: <true|false> }
Field Type Description
renameCollection string The namespace of the collection to rename. The namespace is a combination of the database name and the name of the collection.
to string The new namespace of the collection. If the new namespace specifies a different database, the renameCollection command copies the collection to the new database and drops the source collection.
dropTarget boolean Optional. If true, mongod will drop the target of renameCollection prior to renaming the collection. The default value is false.

Example:

use admin
db.runCommand( { renameCollection: "DBA.xxx", to: "NewDB.xxx" } )
db.runCommand( { renameCollection: "DBA.yyy", to: "NewDB.yyy" } )
...
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!