Partager via


InstanceDatabaseOptions Class

Represents the database options for an instance database.

Espace de noms: Microsoft.SqlServer.Management.Nmo
Assembly: Microsoft.SqlServer.Smo (in microsoft.sqlserver.smo.dll)

Syntaxe

'Déclaration
Public NotInheritable Class InstanceDatabaseOptions
    Inherits NamedSmoObject
public sealed class InstanceDatabaseOptions : NamedSmoObject
public ref class InstanceDatabaseOptions sealed : public NamedSmoObject
public final class InstanceDatabaseOptions extends NamedSmoObject
public final class InstanceDatabaseOptions extends NamedSmoObject

Notes

Use the InstanceDatabaseOptions class to configure the default filegroup and collation for the instance database.

Specifying instance database properties is optional. For more information about default values, see Définition de la base de données d'instance.

If you want to alter the instance database after creating the instance, use the Microsoft SQL Server tools, such as SQL Server Management Studio.

Inheritance Hierarchy

System.Object
   Microsoft.SqlServer.Management.Smo.SmoObjectBase
     Microsoft.SqlServer.Management.Smo.SqlSmoObject
       Microsoft.SqlServer.Management.Smo.NamedSmoObject
        Microsoft.SqlServer.Management.Nmo.InstanceDatabaseOptions

Exemple

The following examples show how to define data files, log files, and database properties for an instance database:

// Define instance database properties
// Create the InstanceDatabaseOptions object
InstanceDatabaseOptions idb = 
    new InstanceDatabaseOptions(myInstance, "MyInstDB");

// Define and add a filegroup
InstanceDatabaseFileGroup idb_fg = 
    new InstanceDatabaseFileGroup(idb, "PRIMARY");
idb.InstanceDatabaseFileGroups.Add(idb_fg);

// Define and add a data file
InstanceDatabaseFile idb_file1 = 
    new InstanceDatabaseFile(idb_fg, "MyInst_PrimaryFile1");
idb_file1.FileName = @"C:\NS\Full\MyInst_PrimaryFile1.mdf";
idb_file1.InitialSize = "5MB";
idb_file1.MaxSize = "15MB";
idb_file1.GrowthIncrement = "10%";
idb_fg.InstanceDatabaseFiles.Add(idb_file1);

// Define and add a log file
InstanceDatabaseLogFile idb_log = 
    new InstanceDatabaseLogFile(idb, "MyInst_LogFile1");
idb_log.FileName = @"C:\NS\Full\MyInst_LogFile1.ldf";
idb_log.InitialSize = "3MB";
idb_log.MaxSize = "10MB";
idb_log.GrowthIncrement = "10%";
idb.InstanceDatabaseLogFiles.Add(idb_log);

// Define database options
idb.CollationName = "Latin1_General_CS_AS";
idb.DefaultFileGroup = "PRIMARY";

// Assign options to Instance.InstanceDatabaseOptions property
myInstance.InstanceDatabaseOptions = idb;
' Create the InstanceDatabaseOptions object
Dim idb As InstanceDatabaseOptions = _
    New InstanceDatabaseOptions(myInstance, "MyInstDB")

' Define and add a filegroup
Dim idb_fg As InstanceDatabaseFileGroup = _
    New InstanceDatabaseFileGroup(idb, "PRIMARY")
idb.InstanceDatabaseFileGroups.Add(idb_fg)

' Define and add a data file
Dim idb_file1 As InstanceDatabaseFile = _
    New InstanceDatabaseFile(idb_fg, "MyInst_PrimaryFile1")
idb_file1.FileName = "C:\NS\Full\MyInst_PrimaryFile1.mdf"
idb_file1.InitialSize = "5MB"
idb_file1.MaxSize = "15MB"
idb_file1.GrowthIncrement = "10%"
idb_fg.InstanceDatabaseFiles.Add(idb_file1)

' Define and add a log file
Dim idb_log As InstanceDatabaseLogFile = _
    New InstanceDatabaseLogFile(idb, "MyInst_LogFile1")
idb_log.FileName = "C:\NS\Full\MyInst_LogFile1.ldf"
idb_log.InitialSize = "3MB"
idb_log.MaxSize = "10MB"
idb_log.GrowthIncrement = "10%"
idb.InstanceDatabaseLogFiles.Add(idb_log)

' Define database options
idb.CollationName = "Latin1_General_CS_AS"
idb.DefaultFileGroup = "PRIMARY"

' Assign options to Instance.InstanceDatabaseOptions property.
myInstance.InstanceDatabaseOptions = idb

Sécurité des threads

Any public static (Shared in Microsoft Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Plateformes

Plateformes de développement

Pour obtenir la liste des plateformes prises en charge, consultez Configuration matérielle et logicielle requise pour l'installation de SQL Server 2005.

Plateformes cibles

Pour obtenir la liste des plateformes prises en charge, consultez Configuration matérielle et logicielle requise pour l'installation de SQL Server 2005.

Voir aussi

Référence

InstanceDatabaseOptions Members
Microsoft.SqlServer.Management.Nmo Namespace

Autres ressources

Définition de la base de données d'instance
CollationName Element (ICF)
DefaultFileGroup Element (ICF)