ALTER TABLE ADD COLUMN会导致索引重建吗? [英] will ALTER TABLE ADD COLUMN result in indexes being rebuild ?

查看:495
本文介绍了ALTER TABLE ADD COLUMN会导致索引重建吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

快速问题伙计们,如果我将一个列添加到现有的包含索引的表中,那么所有索引都会重建吗?

Quick question Guys, if I add a column to an existing table with indexes on it, will all indexes then be rebuild ?

推荐答案

索引提取信息以加速检索信息,索引在创建时绑定到一列或多列(并通过行内容的更改进行更新)。



所以添加一个新的列不会影响以前的索引,因为它们基本上不关心该列。
Indexes extract information for speeding the retrieval of information, and indexes are bound to one or more columns at the time of creation (and updated by changes in row content).

So by adding a new column you will not affect previous indexes since they essentially don't care for that column.


否。索引是现有列的快捷方式排序版本。对于新列,无需重建现有索引。但是,如果更改受索引影响的列的数据类型,则仅重建该索引。
No. Indexes are "shortcut" sorted versions of the existing columns. For new columns, there is no need to rebuild existing indexes. But if you change the datatype of a column that is affected by an index, it rebuilds that index only.


是,

Yes,
 Rebuilding Indexes happens Rebuilding an index drops and re-creates the index.
And Modifies a table definition by altering, adding, or dropping columns and constraints, reassigning and rebuilding partitions, or disabling or enabling constraints and triggers. 





ALTER TABLE



ALTER TABLE

Indexes created as part of a constraint are dropped when the constraint is dropped. Indexes that were created with CREATE INDEX must be dropped with DROP INDEX. The ALTER INDEX statement can be used to rebuild an index part of a constraint definition; the constraint does not have to be dropped and added again with ALTER TABLE.
All indexes and constraints based on a column must be removed before the column can be removed.
When a constraint that created a clustered index is deleted, the data rows that were stored in the leaf level of the clustered index are stored in a nonclustered table. You can drop the clustered index and move the resulting table to another filegroup or partition scheme in a single transaction by specifying the MOVE TO option. The MOVE TO option has the following restrictions:





获取更多信息

msdn part 1 [ ^ ]

msdn part 2 [ ^ ]


这篇关于ALTER TABLE ADD COLUMN会导致索引重建吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆