共用方式為


DisableAllIndexes 方法

停用資料表的所有索引。

命名空間:  Microsoft.SqlServer.Management.Smo
組件:  Microsoft.SqlServer.Smo (在 Microsoft.SqlServer.Smo.dll 中)

語法

'宣告
Public Sub DisableAllIndexes
'用途
Dim instance As Table

instance.DisableAllIndexes()
public void DisableAllIndexes()
public:
void DisableAllIndexes()
member DisableAllIndexes : unit -> unit 
public function DisableAllIndexes()

備註

The table must have been created using the Create() method before the indexes can be disabled.

範例

The following code example shows how to disable all indexes on a table.

C#

Server srv = new Server("(local)");
Database db = srv.Databases["AdventureWorks2008R2"];

Table tb = new Table(db, "Test Table");
Column col1 = new Column(tb, "Name", DataType.NChar(50));
Column col2 = new Column(tb, "ID", DataType.Int);

tb.Columns.Add(col1); 
tb.Columns.Add(col2); 
tb.Create();

tb.DisableAllIndexes();
$tb.Drop();

Powershell

#Connect to the local server and get the AdventureWorks2008R2 database
$srv = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)")
$db = New-Object Microsoft.SqlServer.Management.Smo.Database
$db = $srv.Databases.Item("AdventureWorks2008R2")

#Create the Table
$tb = new-object Microsoft.SqlServer.Management.Smo.Table($db, "Tester Table")
$col1 = new-object Microsoft.SqlServer.Management.Smo.Column($tb, "Name", [Microsoft.SqlServer.Management.Smo.DataType]::NChar(50))
$col2 = new-object Microsoft.SqlServer.Management.Smo.Column($tb, "ID", [Microsoft.SqlServer.Management.Smo.DataType]::Int)
$tb.Columns.Add($col1)
$tb.Columns.Add($col2)
$tb.Create()

$tb.DisableAllIndexes()
$tb.Drop()