将列添加到 Oracle 中的现有索引

发布于 2024-12-19 14:56:10 字数 730 浏览 2 评论 0原文

我有一个相对较大的表(81M 行)及其上的索引。

我想向现有索引添加一列。

我在谷歌上搜索了它,但找不到方法。

我读过 某处将列添加到索引的唯一方法是删除并重新创建它。

然而,这里说将列添加到现有索引是常见的做法。 (尽管作者不推荐这样做。)

那么,是否可以将列添加到现有索引中,如果可能的话,这是一个好的做法吗?

I have a relatively large table (81M rows) and an index on it.

I want to add a column to the existing index.

I searched for it on Google, but I couldn't find a way for it.

I've read somewhere that the only way to add a column to an index is to drop and recreate it.

However, here it says it's common practice to add columns to existing index. (Although the author doesn't recommend it.)

So, is it possible to add columns to existing index and if possible is it good practice?

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

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

发布评论

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

评论(1

吝吻 2024-12-26 14:56:10

如果不删除并重新创建索引,则无法将新列添加到现有索引。

当乔纳森刘易斯谈论“向现有索引添加列”时,他谈论的是删除现有索引并创建新索引。请注意,在他的示例中,“原始索引”和“修改后的索引”均使用 CREATE INDEX 语句列出。该示例中没有 ALTER INDEX 语句可以添加新列而不删除旧列。

放弃和放弃是否是一个好主意?使用附加列重新创建索引取决于许多因素。正如 Jonathan Lewis 指出的那样,在多种情况下,添加额外的列会影响索引的聚类因子,并导致某些现有查询的性能更差。如果不了解您的系统或我们正在讨论的索引,就不可能提供建议。

It is not possible to add a new column to an existing index without dropping and recreating the index.

When Jonathan Lewis is talking about "adding a column to an existing index", he's talking about dropping the existing index and creating a new index. Note in his example, both the "original index" and "modified index" are listed with a CREATE INDEX statement. There are no ALTER INDEX statements in the example that would add a new column without dropping the old column.

Whether it is a good idea to drop & recreate the index with an additional column depends on a number of factors. As Jonathan Lewis points out, there are various situations where adding additional columns will affect the clustering factor of the index and cause some existing queries to perform more poorly. Without knowing anything about your system or the index we're talking about, it's impossible to advise.

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