So führen Sie mehrere Datenbanken in Mongodb zusammen
PHP中文网
PHP中文网 2017-06-21 10:11:34
0
1
1021

Jetzt gibt es DBA, DBB, DBC und NewDB in einer Instanz. Wie importiert man ABC in NewDB?
Die Struktur ist die gleiche, ich habe es versucht For InsertInsertMany, aber die Daten liegen nahe bei 500 W und es funktioniert nicht, nachdem ein paar Leitungen angeschlossen wurden. Und der Wirkungsgrad ist zu gering.
Gibt es eine effiziente Möglichkeit?

PHP中文网
PHP中文网

认证0级讲师

Antworte allen(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" } )
...
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!