索引唯一文本字段的最佳实践是什么?

发布于 2024-10-09 03:41:27 字数 151 浏览 0 评论 0原文

我有一个包含多个文本字段的表,出于性能原因,这些文本字段不能成为主键的一部分。但文本字段需要有全文索引并且是唯一的。

在这种情况下,为每个字段创建全文索引和唯一索引是否合适?

编辑:我正在使用MySQL。我希望有一个通用的非特定于数据库的答案,但显然没有。

I have a table with multiple text fields that cannot be part of the primary key for performance reasons. But the text fields need to have a full-text index AND be unique.

In such a case, is it appropriate to create a full-text index AND a unique index for each of these fields?

EDIT: I am using MySQL. I was hoping there was a general non-DB-specific answer, but apparently there isn't.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

他夏了夏天 2024-10-16 03:41:27

如果您谈论的是 SQL Server,那么可以:首先在这些文本字段上创建唯一索引。然后,您在该唯一索引的子集上创建全文索引。

我不太明白这个问题,因为如果没有唯一索引,您实际上无法创建全文索引。

注意:如果您谈论的不是 SQL Server,请忽略这篇文章并更新问题以指定您正在使用哪个 DBMS。

If you are talking about SQL Server, then yes: First you create a unique index on those text fields. Then you create the full-text index on a subset of that unique index.

I don't really understand the question though because you literally cannot create a full-text index without already having a unique index.

NOTE: If you are not talking about SQL Server then ignore this post and update the question to specify which DBMS you are using.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文