Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Enables all indexes.
Namespace: Microsoft.SqlServer.Management.Smo
Assembly: Microsoft.SqlServer.Smo (in Microsoft.SqlServer.Smo.dll)
Syntax
'Declaration
Public Sub EnableAllIndexes ( _
action As IndexEnableAction _
)
'Usage
Dim instance As Table
Dim action As IndexEnableAction
instance.EnableAllIndexes(action)
public void EnableAllIndexes(
IndexEnableAction action
)
public:
void EnableAllIndexes(
IndexEnableAction action
)
member EnableAllIndexes :
action:IndexEnableAction -> unit
public function EnableAllIndexes(
action : IndexEnableAction
)
Parameter
- action
Typ: Microsoft.SqlServer.Management.Smo.IndexEnableAction
An IndexEnableAction object value that specifies how to enable the indexes.
Beispiele
The following code example shows how to rebuild all indexes on a table by using the EnableAllIndexes function.
C#
Server srv = new Server("(local)");
Database db = srv.Databases["AdventureWorks2012"];
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.EnableAllIndexes(EnableIndexAction.Rebuild);
$tb.Drop();
Powershell
#Connect to the local server and get the AdventureWorks2012 database
$srv = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)")
$db = New-Object Microsoft.SqlServer.Management.Smo.Database
$db = $srv.Databases.Item("AdventureWorks2012")
#Create the Table
$tb = new-object Microsoft.SqlServer.Management.Smo.Table($db, "Test 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.EnableAllIndexes([Microsoft.SqlServer.Management.Smo.EnableIndexAction]::Rebuild)
$tb.Drop()
Siehe auch
Verweis
Microsoft.SqlServer.Management.Smo-Namespace