Databases数据库

A database is a container for collections. 数据库是集合的容器。Each database gets its own set of files on the host file system. 每个数据库在主机文件系统上都有自己的一组文件。A single MongoDB server typically has multiple databases.单个MongoDB服务器通常有多个数据库。

The Databases tab lists the existing databases for your MongoDB deployment. “数据库”选项卡列出了MongoDB部署的现有数据库。To access the Databases tab, click the cluster name in the upper left corner and select the Databases tab.要访问“数据库”选项卡,请单击左上角的群集名称,然后选择“数据库”选项卡。

Database Tab

From this view, you can click a database name in the list to view its collections. 在此视图中,可以单击列表中的数据库名称以查看其集合Alternatively, you can view database collections by clicking the desired database in the left-hand navigation.或者,您可以通过单击左侧导航中所需的数据库来查看数据库集合。

You can also create or drop databases from this view.您还可以从此视图中创建删除数据库。

1

From the Databases tab, click the Create Database button to bring up the Create Database dialog.在“数据库”选项卡中,单击“创建数据库”按钮以打开“创建数据库”对话框。

2

In the dialog, enter the name of the database to create and its first collection. 在对话框中,输入要创建的数据库及其第一个集合的名称。Both the database name and the collection name are required.数据库名称和集合名称都是必需的。

If you want to create a capped collection, select the Capped Collection checkbox and enter the maximum bytes.如果要创建封顶集合,请选中封顶集合复选框并输入最大字节数。

If you want to use custom collation on the newly created collection, select the Use Custom Collation checkbox and select the desired collation settings.如果要对新创建的集合使用自定义排序规则,请选中“使用自定义排序规则”复选框,然后选择所需的排序规则设置。

3
1

From the Databases tab, to delete a database, click on the trash can icon for that database. 从“数据库”选项卡中,要删除数据库,请单击该数据库的垃圾箱图标。A confirmation dialog appears.此时会出现一个确认对话框。

2

In the dialog, enter the name of the database to delete.在对话框中,输入要删除的数据库的名称。

3
  • Creating and dropping databases is not permitted in MongoDB Compass Readonly Edition.MongoDB Compass只读版不允许创建和删除数据库。
  • Creating databases is not permitted if you are connected to a Data Lake.如果连接到数据湖,则不允许创建数据库。