MongoDB: db.repairDatabase() method
db.repairDatabase
The db.repairDatabase() method is used to run a repair routine on the current database.
Syntax:
db.repairDatabase()
Example: MongoDB: db.repairDatabase() method
db.repairDatabase();
Output:
> db.repairDatabase(); { "ok" : 1 }
Retrieve the restaurants data from here
Behavior
Note:
- During normal operations, only use the repairDatabase command and wrappers including db.repairDatabase() in the mongo shell and mongod --repair, to compact database files and/or reclaim disk space. Be aware that these operations remove and do not save any corrupt data during the repair process.
- If you are trying to repair a replica set member, and you have access to an intact copy of your data (e.g. a recent backup or an intact member of the replica set), you should restore from that intact copy, and not use repairDatabase.
Previous:
db.printCollectionStats() method
Next:
db.runCommand() method
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join