C100DBA CRUD Operations Practice Question
Exhibit
db.products.updateOne({ _id: 101 }, { $rename: { 'qty': 'quantity' } })Refer to the exhibit. What is the impact of this operation on the document?
⚠ Common exam trap
Candidates assume $rename creates a copy of the data. They often forget that the original field is completely removed and its value moved to the new field name.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
It deletes the 'qty' field and creates a new 'quantity' field with the same value.
The $rename operator updates the name of a field within a document. It is atomic at the document level. If the field 'qty' exists, it is renamed to 'quantity'. If 'qty' does not exist, the operation does nothing. This is useful for schema migrations or refactoring data models without needing to delete and re-insert the document, which preserves the original _id and other field values.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
It deletes the 'qty' field and creates a new 'quantity' field with the same value.
Why this is correct
The $rename operator logically renames a field. It updates the key name while keeping the value intact. This is an efficient way to refactor document structures when field names need to be updated to match new application requirements or to maintain consistent naming conventions across the dataset.
- ✗
It fails because 'qty' is not a field in the document.
Why it's wrong here
The $rename operator does not fail if the field does not exist. It simply ignores the operation for that document. This behavior is intentional, allowing developers to run migration scripts across heterogeneous collections where some documents may lack the target field without causing errors in the workflow.
- ✗
It replaces the entire document with a new one containing only the quantity field.
Why it's wrong here
The $rename operator only affects the specific field targeted. It does not overwrite the rest of the document. Other fields remain unchanged, which is the desired behavior when performing incremental schema changes or cleanup tasks in production databases that contain large, complex document structures.
- ✗
It creates a new collection named 'quantity'.
Why it's wrong here
The $rename operator is used for renaming fields within a document, not for renaming or creating collections. Collections are managed using the 'renameCollection' database command. Confusing field-level updates with collection-level metadata operations can lead to unintended data loss or corruption of database configuration settings.
About these practice questions
This C100DBA question is part of Courseiva's 222-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official MongoDB exam blueprint
This C100DBA practice question is part of Courseiva's free MongoDB certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the C100DBA exam.