> For the complete MongoDB documentation index, see www.mongodb.com/docs/llms.txt

# Create, View, Drop, and Shard Collections

You can manage the collections in your clusters using the Atlas UI and [`mongosh`.](https://www.mongodb.com/docs/mongodb-shell.md#mongodb-binary-bin.mongosh)

## Required Roles

The following table describes the roles required to manage the collections in an Atlas project:

| Action | Required Roles |
| --- | --- |
| Create Collections | One of the following roles: [`Project Owner`](https://www.mongodb.com/docs/atlas/reference/user-roles.md#mongodb-authrole-Project-Owner) or [`Organization Owner`](https://www.mongodb.com/docs/atlas/reference/user-roles.md#mongodb-authrole-Organization-Owner); [`Project Data Access Admin`](https://www.mongodb.com/docs/atlas/reference/user-roles.md#mongodb-authrole-Project-Data-Access-Admin); [`Project Data Access Read/Write`](https://www.mongodb.com/docs/atlas/reference/user-roles.md#mongodb-authrole-Project-Data-Access-Read-Write) |
| View Collections | At least the [`Project Data Access Read Only`](https://www.mongodb.com/docs/atlas/reference/user-roles.md#mongodb-authrole-Project-Data-Access-Read-Only) role. |
| Drop Collections | One of the following roles: [`Project Owner`](https://www.mongodb.com/docs/atlas/reference/user-roles.md#mongodb-authrole-Project-Owner); [`Project Data Access Admin`](https://www.mongodb.com/docs/atlas/reference/user-roles.md#mongodb-authrole-Project-Data-Access-Admin) |
| Shard Collections | One of the following roles: [`Project Owner`](https://www.mongodb.com/docs/atlas/reference/user-roles.md#mongodb-authrole-Project-Owner); [`Organization Owner`](https://www.mongodb.com/docs/atlas/reference/user-roles.md#mongodb-authrole-Organization-Owner) |

## Create a Collection

**Tip:**

To create the first collection in a new database, see [Create a Database.](https://www.mongodb.com/docs/atlas/atlas-ui/databases.md#std-label-atlas-ui-create-a-db)

**Important:**

You cannot create new collections on the `config` and `system` databases. Atlas will deprecate writing to existing collections on these databases in the near future.

To create a collection in an existing database through the Atlas UI:

1. In Atlas, go to the Data Explorer page for your project

   If it's not already displayed, select the organization that contains your project from the  Organizations menu in the navigation bar.

   If it's not already displayed, select your project from the Projects menu in the navigation bar.

   In the sidebar, click Data Explorer under the Database heading.

   The [Data Explorer](https://cloud.mongodb.com/go?l=https%3A%2F%2Fcloud.mongodb.com%2Fv2%2F%3Cproject%3E%23%2Fmetrics%2FreplicaSet%2F%3Creplset%3E%2Fexplorer) displays.

2. Open the Create Collection dialog box.

   Select or hover over the database, and click the  icon to open the Create Collection dialog box.

3. Enter the Collection Name.

   In the Create Collection dialog box, enter the name of the collection you want to create.

   Atlas also provides Additional preferences. You can choose from the following options:

   - [Create a Clustered Collection](https://www.mongodb.com/docs/atlas/atlas-ui/collections/clustered-collection.md#std-label-atlas-ui-clustered-collection)

   - [Create a Collection with Collation](https://www.mongodb.com/docs/atlas/atlas-ui/collections/collation-collection.md#std-label-atlas-ui-collation-collection)

   **Important:**

   Don't include [sensitive information](https://www.mongodb.com/docs/atlas/production-notes.md#std-label-sensitive-info) in your collection name.

   For more information on MongoDB collection names, see [Naming Restrictions.](https://www.mongodb.com/docs/manual/reference/limits.md#std-label-restrictions-on-db-names)

4. Optional. Specify a time series collection.

   Select whether the collection is a [time series collection](https://www.mongodb.com/docs/manual/core/timeseries-collections/). If you select to create a time series collection, specify the time field and granularity. You can optionally specify the meta field and the time for old data in the collection to expire.

5. Click Create Collection.

   Upon successful creation, the collection appears underneath the database in the Connections sidebar.

## View Collections

To view the databases and collections in the cluster through the Atlas UI:

1. In Atlas, go to the Data Explorer page for your project.

   If it's not already displayed, select the organization that contains your project from the  Organizations menu in the navigation bar.

   If it's not already displayed, select your project from the Projects menu in the navigation bar.

   In the sidebar, click Data Explorer under the Database heading.

   The [Data Explorer](https://cloud.mongodb.com/go?l=https%3A%2F%2Fcloud.mongodb.com%2Fv2%2F%3Cproject%3E%23%2Fmetrics%2FreplicaSet%2F%3Creplset%3E%2Fexplorer) displays.

   IMPORTANT: You can also click the name of a cluster to open the Cluster sidebar, and then click Data Explorer under the Shortcuts heading.

2. View the collections in a database.

   Click on the name of the database.

   **Note:**

   Atlas bases the document count that appears on this tab on cached metadata using [collStats](https://www.mongodb.com/docs/manual/reference/command/collStats/). This count might differ from the actual document count in the collection. For example, an [unexpected shutdown](https://www.mongodb.com/docs/manual/reference/command/collStats/#behavior) can throw off the count. Use the [db.collection.countDocuments()](https://www.mongodb.com/docs/manual/reference/method/db.collection.countDocuments/) method for the most accurate document count.

### Visualize Collection Data

To launch MongoDB Charts to visualize data in your databases and collections.

1. In Atlas, go to the Data Explorer page for your project.

   If it's not already displayed, select the organization that contains your project from the  Organizations menu in the navigation bar.

   If it's not already displayed, select your project from the Projects menu in the navigation bar.

   In the sidebar, click Data Explorer under the Database heading.

   The [Data Explorer](https://cloud.mongodb.com/go?l=https%3A%2F%2Fcloud.mongodb.com%2Fv2%2F%3Cproject%3E%23%2Fmetrics%2FreplicaSet%2F%3Creplset%3E%2Fexplorer) displays.

   IMPORTANT: You can also click the name of a cluster to open the Cluster sidebar, and then click Data Explorer under the Shortcuts heading.

2. Launch MongoDB Charts.

   To visualize data in MongoDB Charts from the Atlas UI, click Visualize Your Data when viewing a specific database or collection. Charts loads the data source and you can start building a chart in the Charts view. For detailed steps, see [Build Charts.](https://www.mongodb.com/docs/charts/build-charts/)

## Drop a Collection

To drop a collection, including its documents and indexes, through the Atlas UI:

1. In Atlas, go to the Data Explorer page for your project.

   If it's not already displayed, select the organization that contains your project from the  Organizations menu in the navigation bar.

   If it's not already displayed, select your project from the Projects menu in the navigation bar.

   In the sidebar, click Data Explorer under the Database heading.

   The [Data Explorer](https://cloud.mongodb.com/go?l=https%3A%2F%2Fcloud.mongodb.com%2Fv2%2F%3Cproject%3E%23%2Fmetrics%2FreplicaSet%2F%3Creplset%3E%2Fexplorer) displays.

   IMPORTANT: You can also click the name of a cluster to open the Cluster sidebar, and then click Data Explorer under the Shortcuts heading.

2. Drop the collection.

   In the Connections sidebar, click the  icon next to the collection you want to drop. In the drop-down menu that appears, click Drop Collection.

3. Confirm the collection to delete.

   Confirm by typing the name of the collection, and click Drop Database.

## Shard a Collection

If you have large data sets and perform high throughput operations, you can [shard](https://www.mongodb.com/docs/manual/sharding/) a collection to distribute data across the shards.

The Atlas UI supports sharding a collection only for Global Writes collections on global clusters with [Atlas-Managed Sharding](https://www.mongodb.com/docs/atlas/tutorial/create-global-cluster/#select-your-sharding-configuration) enabled. To learn more, see [Shard a Global Collection for Global Writes.](https://www.mongodb.com/docs/atlas/shard-global-collection.md#std-label-shard-global-collection)

For all other collections, you must use [`mongosh`](https://www.mongodb.com/docs/mongodb-shell.md#mongodb-binary-bin.mongosh) to shard the collection. You cannot use the Atlas UI. First confirm that your cluster is a [sharded cluster](https://www.mongodb.com/docs/atlas/cluster-additional-settings.md#std-label-create-cluster-sharding), then take the following steps to shard the collection in [`mongosh`:](https://www.mongodb.com/docs/mongodb-shell.md#mongodb-binary-bin.mongosh)

1. Connect to MongoDB from [`mongosh`](https://www.mongodb.com/docs/mongodb-shell.md#mongodb-binary-bin.mongosh).

   See [Connect to a Cluster via mongosh.](https://www.mongodb.com/docs/atlas/mongo-shell-connection.md#std-label-connect-mongo-shell)

2. Optional: Create an index on the shard key if the collection that you wish to shard has data and is not empty.

   To create an index on the shard key, run the following command:

   ```sh
   db.<collection-name>.createIndex({<shard_key_definition>})
   ```

   **Example:**

   To create an index on the shard key for the `sample_analytics.customers` collection:

   ```sh
   db.sample_analytics.createIndex( { "username": 1 } )
   ```

   To learn  more, see:

   - [Choose a Shard Key](https://www.mongodb.com/docs/manual/core/sharding-choose-a-shard-key/)

   - [createIndexes](https://www.mongodb.com/docs/manual/reference/command/createIndexes/)

3. Shard the collection that you want to shard.

   To shard a collection, run the following command:

   ```sh
   sh.shardCollection("<database>.<collection>", { "<indexed-field>" : 1 } )
   ```

   **Example:**

   To shard the `sample_analytics.customers` collection:

   ```sh
   sh.shardCollection("sample_analytics.customers", { "username" : 1 } )
   ```

   WARNING: If you shard a collection that already has a MongoDB Search index, you might experience a brief period of incomplete search results while the index is building on a shard. Also, if you add a shard for an already sharded collection that contains a MongoDB Search index, your search queries against that collection might return incomplete results until the initial sync process completes on the added shards. To learn more, see [initial sync process.](https://www.mongodb.com/docs/search/performance/index-performance.md#std-label-troubleshoot-initial-sync)

   To learn more, see [Shard a Collection](https://www.mongodb.com/docs/manual/tutorial/deploy-shard-cluster/#shard-a-collection) in the MongoDB manual.
