gpt4 book ai didi

mongodb - "system."在 MongoDB 中的集合名称中

转载 作者:行者123 更新时间:2023-12-02 02:11:57 25 4
gpt4 key购买 nike

我刚刚发现 MongoDB 表现出一种奇怪的行为。

显然,任何带有字符串“system”的集合名称。其中的任何地方都将无法正常工作。

更糟糕的是,它甚至不会告诉您有什么问题!

这确实是一个好奇的问题,但是有人知道为什么会发生这种情况吗?它有记录在某处吗?

我的假设是它使用“system.*”集合在内部存储内容(例如索引)并且不希望您弄乱它们,但这对我来说似乎不是正确的行为。

最佳答案

你是对的,“system.*”是MongoDB在每个数据库中使用的保留集合命名空间。

用于存储索引、用户等。

SQL Server 也有很多这样的表,我不相信它们会警告您不要使用它们:)

但是您始终可以提出对此类功能的请求:http://jira.mongodb.org/

您可以通过运行...来查看它们

>显示集合

你会看到类似......的东西

系统索引

system.users

因此,您可以查看索引,例如:

> db.system.indexes.find()

来自 MongoDB 文档:

The .system.* namespaces in MongoDB are special and contain database system information. System collections include:

  • system.namespaces lists all namespaces.
  • system.indexes lists all indexes.
  • Additional namespace / index metadata exists in the database.ns files, and is opaque.
  • system.profile stores database profiling information.
  • system.users lists users who may access the database.
  • local.sources stores replica slave configuration data and state.
  • Information on the structure of a stored object is stored within the object itself. See BSON .

There are several restrictions on manipulation of objects in the system collections. Inserting in system.indexes adds an index, but otherwise that table is immutable (the special drop index command updates it for you). system.users is modifiable. system.profile is droppable.

http://docs.mongodb.org/manual/reference/system-collections/

关于mongodb - "system."在 MongoDB 中的集合名称中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4665244/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com