Indexes Collection
后续版本的 Microsoft SQL Server 将删除该功能。 请避免在新的开发工作中使用该功能,并着手修改当前还在使用该功能的应用程序。
The Indexes collection contains Index objects that reference indexes that implement Microsoft SQL Server constraints and user-defined access paths.
注释
With the Indexes collection, you can:
Create a user-defined access path or unique constraint on data maintained by a SQL Server index.
Remove a SQL Server index.
For more information about creating a SQL Server index using SQL-DMO, see Index Object.
To remove a SQL Server index:
Use the Remove method of the Indexes collection, as in:
oTables("Employees").Indexes.Remove("LastName")
When using the Item or Remove method, the Indexes collection supports member identification using either name or ordinal reference syntax. For example:
Set oIndex = oTable.Indexes("LastName")
Or
Set oIndex = oTable.Indexes(2)
![]() |
---|
Creating or removing indexes by using the Indexes collection requires appropriate privilege. The SQL Server login used for SQLServer object connection must be a member of the fixed role db_ddladmin or a role with greater privilege. |