Courseiva
Sharding →easyMultiple Choice

C100DBA Sharding Practice Question

A database administrator is setting up a new sharded cluster and needs to enable sharding on a database named 'sales' before sharding any collections. Which command should be executed on mongos to enable sharding for this database?

⚠ Common exam trap

Watch out — candidates often confuse the command to enable sharding on a database with the command to shard a specific collection or add a shard to the cluster.

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

✓

sh.enableSharding("sales")

To enable sharding on a database in MongoDB, you must run sh.enableSharding() on mongos with the database name. This marks the database as sharding-enabled in the config servers, allowing collections within it to be sharded. The other commands either shard a collection, add a shard, or use incorrect syntax.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    db.runCommand({enableSharding: "sales"}) on the admin database

    Why it's wrong here

    While the enableSharding command exists, it must be run against the admin database. Running db.runCommand() from a non-admin database will fail. The helper sh.enableSharding() automatically targets the admin database and is the correct method to use from mongos.

  • ✗

    sh.addShard("sales")

    Why it's wrong here

    sh.addShard() is used to add a shard (a replica set) to the cluster, not to enable sharding on a database. The argument should be a replica set name and host list, not a database name. Using this command with a database name will result in an error because it expects a shard connection string.

  • ✗

    sh.shardCollection("sales", {_id: "hashed"})

    Why it's wrong here

    sh.shardCollection() is used to shard a specific collection, not to enable sharding on a database. It requires the full namespace of the collection, such as "sales.orders". Running it without a collection name will fail. Enabling sharding on the database must be done first with sh.enableSharding().

  • ✓

    sh.enableSharding("sales")

    Why this is correct

    The sh.enableSharding() method is the correct command to enable sharding on a specific database. It must be run on mongos and takes the database name as an argument. Once enabled, collections within that database can be sharded using sh.shardCollection(). This is a prerequisite step before sharding any collection in the database.

About these practice questions

One of 222 original C100DBA practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

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.