Skip to main content

Posts

Showing posts with the label Mongodb Change Rename collection name

5 Best Ways to Rename MongoDB Collection [Rename]

“ How can I Rename a collection in MongoDB ?” Definition : “Rename or changes the name of an existing collection”. Try the Video live example of the code shown in this page using Robomongo ! Syntax:- { renameCollection: "Original_collection_name>" , to: "<New_collection_name>" , dropTarget: < true | false >} What is “ renameCollection ”? It is the name of the original collection to rename. What is “ to ”? It is the new name of the collection. What is “ dropTarget ”? If dropTarget is “true”, mongod will drop the target of renameCollection before to renaming the collection. The default value is “false”. Examples :- db.Original_Coll_Name.renameCollection( 'new_Coll_Name' ); // The “ db.collection.renameCollection() ” is not supported on sharded collections. // OR db.Original_Coll_Name.renameCollection( 'ifAlreadyExistColl' , true ); > show dbs admin 0 . 000 GB demoDB 0 . 0...