Database-Klasse

Represents an SQL Server database.

Vererbungshierarchie

System.Object
  Microsoft.SqlServer.Management.Smo.SmoObjectBase
    Microsoft.SqlServer.Management.Smo.SqlSmoObject
      Microsoft.SqlServer.Management.Smo.NamedSmoObject
        Microsoft.SqlServer.Management.Smo.ScriptNameObjectBase
          Microsoft.SqlServer.Management.Smo.Database

Namespace:  Microsoft.SqlServer.Management.Smo
Assembly:  Microsoft.SqlServer.Smo (in Microsoft.SqlServer.Smo.dll)

Syntax

'Declaration
<PhysicalFacetAttribute> _
<EvaluationModeAttribute(AutomatedPolicyEvaluationMode.CheckOnSchedule)> _
Public NotInheritable Class Database _
    Inherits ScriptNameObjectBase _
    Implements ICreatable, IAlterable, IDroppable, IRenamable,  _
    IExtendedProperties, IScriptable, IDatabaseOptions, IDmfFacet, ISfcSupportsDesignMode
'Usage
Dim instance As Database
[PhysicalFacetAttribute]
[EvaluationModeAttribute(AutomatedPolicyEvaluationMode.CheckOnSchedule)]
public sealed class Database : ScriptNameObjectBase, 
    ICreatable, IAlterable, IDroppable, IRenamable, IExtendedProperties, 
    IScriptable, IDatabaseOptions, IDmfFacet, ISfcSupportsDesignMode
[PhysicalFacetAttribute]
[EvaluationModeAttribute(AutomatedPolicyEvaluationMode::CheckOnSchedule)]
public ref class Database sealed : public ScriptNameObjectBase, 
    ICreatable, IAlterable, IDroppable, IRenamable, IExtendedProperties, 
    IScriptable, IDatabaseOptions, IDmfFacet, ISfcSupportsDesignMode
[<SealedAttribute>]
[<PhysicalFacetAttribute>]
[<EvaluationModeAttribute(AutomatedPolicyEvaluationMode.CheckOnSchedule)>]
type Database =  
    class 
        inherit ScriptNameObjectBase 
        interface ICreatable 
        interface IAlterable 
        interface IDroppable 
        interface IRenamable 
        interface IExtendedProperties 
        interface IScriptable 
        interface IDatabaseOptions 
        interface IDmfFacet 
        interface ISfcSupportsDesignMode 
    end
public final class Database extends ScriptNameObjectBase implements ICreatable, IAlterable, IDroppable, IRenamable, IExtendedProperties, IScriptable, IDatabaseOptions, IDmfFacet, ISfcSupportsDesignMode

Der Database-Typ macht folgende Elemente verfügbar.

Konstruktoren

  Name Beschreibung
Öffentliche Methode Database() Initializes a new instance of the Database class.
Öffentliche Methode Database(Server, String) Initializes a new instance of the Database class on the specified server and with the specified name.

Zum Anfang

Eigenschaften

  Name Beschreibung
Öffentliche Eigenschaft ActiveConnections Gets the number of active connections to the database.
Öffentliche Eigenschaft ActiveDirectory Veraltet Gets the information about the Active Directory settings for the database.
Öffentliche Eigenschaft AnsiNullDefault Gets or sets a value that specifies whether the ANSI_NULL_DEFAULT database option is active.
Öffentliche Eigenschaft AnsiNullsEnabled Gets or sets a value that specifies whether the ANSI_NULLS_ENABLED database option is active.
Öffentliche Eigenschaft AnsiPaddingEnabled Gets or sets a value that specifies whether the ANSI_PADDING_ENABLED database option is active.
Öffentliche Eigenschaft AnsiWarningsEnabled Gets or sets a value that specifies whether the ANSI_WARNINGS_ENABLED database option is active.
Öffentliche Eigenschaft ApplicationRoles Gets a collection of ApplicationRole objects. Each ApplicationRole object represents an application role defined on the database.
Öffentliche Eigenschaft ArithmeticAbortEnabled Gets or sets a value that specifies whether the ARITHMETICABORT database option is active.
Öffentliche Eigenschaft Assemblies Gets a collection of SqlAssembly objects. Each SqlAssembly object represents an assembly defined on the database.
Öffentliche Eigenschaft AsymmetricKeys Gets a collection of AsymmetricKey objects. Each AsymmetricKey object represents an asymmetric key defined on the database.
Öffentliche Eigenschaft AutoClose Gets or sets a value that specifies whether the AUTOCLOSE database option is set.
Öffentliche Eigenschaft AutoCreateStatisticsEnabled Gets a value that specifies whether statistics are automatically created for the database.
Öffentliche Eigenschaft AutoShrink Gets or sets a value that specifies whether the AUTO_SHRINK database option is active.
Öffentliche Eigenschaft AutoUpdateStatisticsAsync Gets or sets a value that specifies whether the AUTOUPDATESTATISTICSASYNC database option is active.
Öffentliche Eigenschaft AutoUpdateStatisticsEnabled Gets or sets a value that specifies whether statistics are automatically updated for the database.
Öffentliche Eigenschaft AvailabilityDatabaseSynchronizationState Gets the synchronization state of the availability database.
Öffentliche Eigenschaft AvailabilityGroupName Gets the availability group name in the database.
Öffentliche Eigenschaft BrokerEnabled Gets or sets a value that specifies whether the Service Broker service is enabled.
Öffentliche Eigenschaft CaseSensitive Gets a value that specifies whether uppercase letters and lowercase letters are evaluated as equal.
Öffentliche Eigenschaft Certificates Gets a collection of Certificate objects. Each Certificate object represents a certificate defined on the database.
Öffentliche Eigenschaft ChangeTrackingAutoCleanUp Gets or sets a value that specifies whether the CHANGE_TRACKING_AUTO_CLEANUP OPTION is enabled.
Öffentliche Eigenschaft ChangeTrackingEnabled Gets or sets a value that specifies whether the CHANGE_TRACKING_VALUE option is enabled
Öffentliche Eigenschaft ChangeTrackingRetentionPeriod Gets or sets the CHANGE_TRACKING_RETENTION_PERIOD value.
Öffentliche Eigenschaft ChangeTrackingRetentionPeriodUnits Gets or sets the unit type for a retention period value.
Öffentliche Eigenschaft CloseCursorsOnCommitEnabled Gets or sets a value that specifies whether the CURSOR_CLOSE_ON_COMMIT database option is active.
Öffentliche Eigenschaft Collation Gets or sets the default collation used by the database.
Öffentliche Eigenschaft CompatibilityLevel Gets or sets the compatibility level for the database.
Öffentliche Eigenschaft ConcatenateNullYieldsNull Gets or sets a value that specifies whether the CONCAT_NULL_YIELDS_NULL database option is active.
Öffentliche Eigenschaft ContainmentType Gets or sets the type of containment.
Öffentliche Eigenschaft CreateDate Gets the date that the database was created.
Öffentliche Eigenschaft DatabaseAuditSpecifications Gets a collection of DatabaseAuditSpecification objects. Each DatabaseAuditSpecification object represents a database audit specification defined on the server.
Öffentliche Eigenschaft DatabaseEncryptionKey Gets a DataBaseEncryptionKey data type.
Öffentliche Eigenschaft DatabaseGuid Gets the Guid value that uniquely identifies the database.
Öffentliche Eigenschaft DatabaseOptions Gets the DatabaseOptions object that contains configuration options for the database.
Öffentliche Eigenschaft DatabaseOwnershipChaining Gets or sets a value that specifies whether the database ownership chaining is active.
Öffentliche Eigenschaft DatabaseSnapshotBaseName Gets the name of the snapshot base for the database.
Öffentliche Eigenschaft DataSpaceUsage Gets the space used by the data in the database.
Öffentliche Eigenschaft DateCorrelationOptimization Gets or sets a value that specifies whether the date correlation optimization is active.
Öffentliche Eigenschaft DboLogin Gets a value that specifies whether the current user is logged on as the database owner (DBO).
Öffentliche Eigenschaft DefaultFileGroup Gets the default file group used by the database.
Öffentliche Eigenschaft DefaultFileStreamFileGroup Gets the file group name for the default file stream.
Öffentliche Eigenschaft DefaultFullTextCatalog Gets the default full-text catalog used by the database.
Öffentliche Eigenschaft DefaultFullTextLanguage Gets the default full text language.
Öffentliche Eigenschaft DefaultLanguage Gets or sets the default language.
Öffentliche Eigenschaft Defaults Gets a collection of Default objects. Each Default object represents a default defined on the database.
Öffentliche Eigenschaft DefaultSchema Gets the default schema of the user.
Öffentliche Eigenschaft EncryptionEnabled Gets or sets a value that indicates whether the data encryption is enabled.
Öffentliche Eigenschaft Events Gets the events associated with the database.
Öffentliche Eigenschaft ExtendedProperties Gets the extended properties of the database.
Öffentliche Eigenschaft ExtendedStoredProcedures Gets a collection of ExtendedStoredProcedure objects. Each ExtendedStoredProcedure object represents an extended stored procedure defined on the database.
Öffentliche Eigenschaft Federations Gets a collection of Federation objects. Each Federation represents a data being partitioned on the database.
Öffentliche Eigenschaft FileGroups Gets a collection of FileGroup objects. Each FileGroup object represents a file group defined on the database.
Öffentliche Eigenschaft FilestreamDirectoryName Gets or sets the name of file stream share directory.
Öffentliche Eigenschaft FilestreamNonTransactedAccess Gets or sets the file stream non-transacted access setting for database.
Öffentliche Eigenschaft FullTextCatalogs Gets a collection of FullTextCatalog objects. Each FullTextCatalog object represents a full-text catalog defined on the database.
Öffentliche Eigenschaft FullTextStopLists Gets a collection of FullTextStopList objects. Each FullTextStopList object represents a full text stop list defined on the server.
Öffentliche Eigenschaft HonorBrokerPriority Gets or sets a value that specifies whether the priority specified by the broker is acknowledged or not.
Öffentliche Eigenschaft ID Gets the database ID value that uniquely identifies the database.
Öffentliche Eigenschaft IndexSpaceUsage Gets the space used by the indexes in the database.
Öffentliche Eigenschaft IsAccessible Gets a value that specifies whether the database can be accessed.
Öffentliche Eigenschaft IsDatabaseSnapshot Gets a value that specifies whether the database is a snapshot database.
Öffentliche Eigenschaft IsDatabaseSnapshotBase Gets a value that specifies whether the database is the base database for a snapshot database.
Öffentliche Eigenschaft IsDbAccessAdmin Gets a value that specifies whether the current user is a member of the DbAccessAdmin database role.
Öffentliche Eigenschaft IsDbBackupOperator Gets a value that specifies whether the current user is a member of the DbBackupOperator database role.
Öffentliche Eigenschaft IsDbDatareader Gets a value that specifies whether the current user is a member of the DbDatareader database role.
Öffentliche Eigenschaft IsDbDatawriter Gets a value that specifies whether the current user is a member of the DbDatawriter database role.
Öffentliche Eigenschaft IsDbDdlAdmin Gets a value that specifies whether the current user is a member of the DbDdlAdmin database role.
Öffentliche Eigenschaft IsDbDenyDatareader Gets a value that specifies whether the current user is a member of the DbDenyDatareader database role.
Öffentliche Eigenschaft IsDbDenyDatawriter Gets a value that specifies whether the current member is a member of the DbDenyDatawriter database.
Öffentliche Eigenschaft IsDbManager Gets a value that specifies whether the current login is a database manager in SQL-Datenbank.
Öffentliche Eigenschaft IsDbOwner Gets a value that specifies whether the current user is a member of the DbOwner database role.
Öffentliche Eigenschaft IsDbSecurityAdmin Gets a value that specifies whether the current user is a member of the DbSecurityAdmin database role.
Öffentliche Eigenschaft IsFederationMember Gets or sets a value that specifies whether the database is a member of federation.
Öffentliche Eigenschaft IsFullTextEnabled Gets or sets a value that specifies whether the database is enabled for full-text search.
Öffentliche Eigenschaft IsLoginManager Gets a value that specifies whether the current login is a login manager in SQL-Datenbank.
Öffentliche Eigenschaft IsMailHost Gets a value that specifies whether the database is configured as a mail host.
Öffentliche Eigenschaft IsManagementDataWarehouse Gets a value that specifies whether the database is a management data warehouse.
Öffentliche Eigenschaft IsMirroringEnabled Gets a value that specifies whether mirroring is enabled on the database.
Öffentliche Eigenschaft IsParameterizationForced Gets or sets a value that specifies whether parameterization is forced on the database.
Öffentliche Eigenschaft IsReadCommittedSnapshotOn Gets or sets a value that specifies whether transactions with the read committed isolation level use row versioning.
Öffentliche Eigenschaft IsSystemObject Gets a value that specifies whether the database is a system object or a user-defined database.
Öffentliche Eigenschaft IsUpdateable Gets a value that specifies whether the database can be updated.
Öffentliche Eigenschaft IsVarDecimalStorageFormatEnabled Gets or sets a value that specifies whether VarDecimal storage is enabled.
Öffentliche Eigenschaft LastBackupDate Gets the date and time when the database was last backed up.
Öffentliche Eigenschaft LastDifferentialBackupDate Gets the date and time when the last differential backup was performed.
Öffentliche Eigenschaft LastLogBackupDate Gets the date and time when the transaction log was last backed up.
Öffentliche Eigenschaft LocalCursorsDefault Gets or sets a value that specifies whether the local server cursors are used by default.
Öffentliche Eigenschaft LogFiles Gets a collection of LogFile objects. Each LogFile object represents a log file defined on the database.
Öffentliche Eigenschaft LogReuseWaitStatus Gets the type of operation on which the reuse of transaction log space is waiting.
Öffentliche Eigenschaft MasterKey Gets the master key that is used to encrypt the private keys of certificates.
Öffentliche Eigenschaft MirroringFailoverLogSequenceNumber Gets the log sequence number at last failover.
Öffentliche Eigenschaft MirroringID Gets the ID value that uniquely identifies the mirroring partnership.
Öffentliche Eigenschaft MirroringPartner Gets or sets the address of the Database Engine (Datenbankmodul) instance that is the partner server for database mirroring.
Öffentliche Eigenschaft MirroringPartnerInstance Gets the instance of SQL Server on which the mirroring partner is configured.
Öffentliche Eigenschaft MirroringRedoQueueMaxSize Gets the maximum size of the redo queue of the mirror server instance in KB.
Öffentliche Eigenschaft MirroringRoleSequence Gets the role sequence number for primary/backup roles played by the mirroring partners.
Öffentliche Eigenschaft MirroringSafetyLevel Gets or sets the mirroring safety level.
Öffentliche Eigenschaft MirroringSafetySequence Gets the role sequence number for safety levels for the mirroring partners.
Öffentliche Eigenschaft MirroringStatus Gets the status of the database and the database mirroring session.
Öffentliche Eigenschaft MirroringTimeout Gets or sets the maximum time, in seconds, that the principal server instance waits for a PING message from another instance in the mirroring session before assuming the other instance is disconnected.
Öffentliche Eigenschaft MirroringWitness Gets or sets the name of the Database Engine (Datenbankmodul) instance of the database mirroring witness server.
Öffentliche Eigenschaft MirroringWitnessStatus Gets the status of the mirroring witness server.
Öffentliche Eigenschaft Name Gets or sets the name of the database. (Überschreibt NamedSmoObject.Name.)
Öffentliche Eigenschaft NestedTriggersEnabled Gets or sets a value that indicates whether the nested triggers are enabled.
Öffentliche Eigenschaft NumericRoundAbortEnabled Gets or sets a value that specifies whether the NUMERIC_ROUNDABORT database option is active.
Öffentliche Eigenschaft Owner Gets the database principal that is the owner of the database.
Öffentliche Eigenschaft PageVerify Gets or sets the type of page integrity check that SQL Server performs when reading database pages.
Öffentliche Eigenschaft Parent Gets or sets the Server object that is the parent of the Database object.
Öffentliche Eigenschaft PartitionFunctions Gets a collection of PartitionFunction objects. Each PartitionFunction object represents a partition function defined on the database.
Öffentliche Eigenschaft PartitionSchemes Gets a collection of PartitionScheme objects. Each PartitionScheme object represents a partition scheme defined on the database.
Öffentliche Eigenschaft PlanGuides Gets a collection of plan guides associated with a database.
Öffentliche Eigenschaft PrimaryFilePath Gets the operating system directory that contains the primary file for the database.
Öffentliche Eigenschaft Properties Gets a collection of Property objects that represent the object properties. (Geerbt von SqlSmoObject.)
Öffentliche Eigenschaft QuotedIdentifiersEnabled Gets or sets a value that specifies whether identifiers delimited by double quotation marks (" ") are Transact-SQL reserved keywords or contain characters not usually allowed by the Transact-SQL syntax rules.
Öffentliche Eigenschaft ReadOnly Gets or sets a value that specifies whether the database is read-only.
Öffentliche Eigenschaft RecoveryForkGuid Gets the GUID value that specifies the recovery fork on which the database is currently active.
Öffentliche Eigenschaft RecoveryModel Gets or sets the recovery model for the database.
Öffentliche Eigenschaft RecursiveTriggersEnabled Gets or sets a value that specifies whether recursive triggers are enabled on the database.
Öffentliche Eigenschaft ReplicationOptions Gets the active replication settings for a database.
Öffentliche Eigenschaft Roles Gets a collection of DatabaseRole objects. Each DatabaseRole object represents a role defined on the database.
Öffentliche Eigenschaft Rules Gets a collection of Rule objects. Each Rule object represents a rule defined on the database.
Öffentliche Eigenschaft Schemas Gets a collection of Schema objects. Each Schema object represents a schema defined on the database.
Öffentliche Eigenschaft SearchPropertyLists Gets the SearchPropertyListCollection associated with this object.
Öffentliche Eigenschaft Sequences Gets the SequenceCollection associated with this object.
Öffentliche Eigenschaft ServiceBroker Gets the ServiceBroker object that represents the Service Broker.
Öffentliche Eigenschaft ServiceBrokerGuid Gets the Guid object that uniquely identifies the instance of Service Broker.
Öffentliche Eigenschaft Size Gets the size of the database in MB.
Öffentliche Eigenschaft SnapshotIsolationState Gets the snapshot isolation state for the database.
Öffentliche Eigenschaft SpaceAvailable Gets the available space in the database in KB.
Öffentliche Eigenschaft State Gets the state of the referenced object. (Geerbt von SmoObjectBase.)
Öffentliche Eigenschaft Status Gets the database status.
Öffentliche Eigenschaft StoredProcedures Gets a collection of StoredProcedure objects. Each StoredProcedure object represents a stored procedure defined on the database.
Öffentliche Eigenschaft SymmetricKeys Gets a collection of SymmetricKey objects. Each SymmetricKey object represents a symmetric key defined on the database.
Öffentliche Eigenschaft Synonyms Gets a collection of Synonym objects. Each Synonym object represents a synonym defined on the database.
Öffentliche Eigenschaft Tables Gets a collection of Table objects. Each Table object represents a table defined on the database.
Öffentliche Eigenschaft TargetRecoveryTime Gets or sets the target recovery time of the used database.
Öffentliche Eigenschaft TransformNoiseWords Gets a value that indicates whether an object that sets the transform noise words configuration option is used.
Öffentliche Eigenschaft Triggers Gets a collection of DatabaseDdlTrigger objects. Each DatabaseDdlTrigger object represents a trigger defined on the database.
Öffentliche Eigenschaft Trustworthy Gets or sets a value that indicates whether the instance of SQL Server 2005 trusts the database and the contents within it.
Öffentliche Eigenschaft TwoDigitYearCutoff Gets or sets the specified object that is used to set the two digit year cutoff configuration option.
Öffentliche Eigenschaft Urn Gets the Uniform Resource Name (URN) address value that uniquely identifies the object. (Geerbt von SqlSmoObject.)
Öffentliche Eigenschaft UserAccess Gets or sets the database user access.
Öffentliche Eigenschaft UserData Gets or sets user-defined data associated with the referenced object. (Geerbt von SmoObjectBase.)
Öffentliche Eigenschaft UserDefinedAggregates Gets a collection of UserDefinedAggregate objects. Each UserDefinedAggregate object represents a user-defined aggregate defined on the database.
Öffentliche Eigenschaft UserDefinedDataTypes Gets a collection of UserDefinedDataType objects. Each UserDefinedDataType object represents a user-defined data type on the database.
Öffentliche Eigenschaft UserDefinedFunctions Gets a collection of UserDefinedFunction objects. Each UserDefinedFunction object represents a user-defined function on the database.
Öffentliche Eigenschaft UserDefinedTableTypes Gets a collection of UserDefinedTableType objects. Each UserDefinedTableType object represents a user-defined table type on the database.
Öffentliche Eigenschaft UserDefinedTypes Gets a collection of UserDefinedType objects. Each UserDefinedType object represents a user-defined type on the database.
Öffentliche Eigenschaft UserName Gets the database user name.
Öffentliche Eigenschaft Users Gets a collection of User objects. Each User object represents a user who is defined on the database.
Öffentliche Eigenschaft Version Gets the version of the instance of SQL Server that was used to create the database.
Öffentliche Eigenschaft Views Gets a collection of View objects. Each View object represents a view defined on the database.
Öffentliche Eigenschaft XmlSchemaCollections Gets a collection of XmlSchemaCollection objects. Each XmlSchemaCollection object represents an XML schema defined on the database.

Zum Anfang

Methoden

  Name Beschreibung
Öffentliche Methode Alter() Updates any Database object property changes on the instance of SQL Server. 
Öffentliche Methode Alter(TimeSpan) Updates any Database object property changes on the instance of SQL Server. 
Öffentliche Methode Alter(TerminationClause) Updates any Database object property changes on the instance of SQL Server. 
Öffentliche Methode ChangeMirroringState Changes the mirroring configuration as specified by the options.
Öffentliche Methode CheckAllocations Scans all pages of the referenced database and tests pages to help ensure integrity.
Öffentliche Methode CheckAllocationsDataOnly Scans all pages of the referenced database and tests only the data to help ensure integrity.
Öffentliche Methode CheckCatalog Tests the integrity of the database catalog.
Öffentliche Methode CheckIdentityValues Verifies the integrity of all identity columns in tables in the database.
Öffentliche Methode Checkpoint Issues a checkpoint.
Öffentliche Methode CheckTables(RepairType) Tests the integrity of database pages for all tables and indexes defined on the tables of the database.
Öffentliche Methode CheckTables(RepairType, RepairOptions) Tests the integrity of database pages for all tables and indexes defined on the tables of the database.
Öffentliche Methode CheckTables(RepairType, RepairStructure) Tests the integrity of database pages for all tables and indexes defined on the tables of the database.
Öffentliche Methode CheckTables(RepairType, RepairOptions, RepairStructure) Tests the integrity of database pages for all tables and indexes defined on the tables of the database.
Öffentliche Methode CheckTablesDataOnly() Tests integrity of data in pages that store data for all tables and indexes defined on the tables of the referenced database.
Öffentliche Methode CheckTablesDataOnly(RepairOptions) Tests integrity of data in pages that store data for all tables and indexes defined on the tables of the referenced database, with the specified repair options.
Öffentliche Methode CheckTablesDataOnly(RepairStructure) Tests integrity of data in pages that store data for all tables and indexes defined on the tables of the referenced database with the specified repair structure.
Öffentliche Methode CheckTablesDataOnly(RepairOptions, RepairStructure) Tests integrity of data in pages that store data for all tables and indexes defined on the tables of the referenced database with the specified repair options and repair structure.
Öffentliche Methode Create() Creates a database on the instance of SQL Server as defined by the Database object.
Öffentliche Methode Create(Boolean) Creates a database on the instance of SQL Server as defined by the Database object.
Öffentliche Methode Deny(DatabasePermissionSet, String) Denies the specified set of permissions for the specified grantee on the database.
Öffentliche Methode Deny(DatabasePermissionSet, array<String[]) Denies the specified set of permissions for the specified grantees on the database.
Öffentliche Methode Deny(DatabasePermissionSet, String, Boolean) Denies the specified set of permissions for the specified grantee and other users who the grantee granted the specified set of permissions on the database.
Öffentliche Methode Deny(DatabasePermissionSet, array<String[], Boolean) Denies the specified set of permissions for the specified grantees and other users who the grantee granted the specified set of permissions on the database.
Öffentliche Methode DisableAllPlanGuides Disables all Plan Guides in a database.
Öffentliche Methode Discover Discovers a list of type Object. (Geerbt von SqlSmoObject.)
Öffentliche Methode Drop Drops the database.
Öffentliche Methode DropAllPlanGuides Drops all Plan Guides in a database.
Öffentliche Methode DropBackupHistory Drops the backup history for the database.
Öffentliche Methode EnableAllPlanGuides Enables all Plan Guides in a database.
Öffentliche Methode EnumBackupSetFiles() Returns a DataTable listing files contained in a backup set.
Öffentliche Methode EnumBackupSetFiles(Int32) Returns a Data table that lists the files in a backup set
Öffentliche Methode EnumBackupSets Returns a DataTable listing the backup sets associated with a database.
Öffentliche Methode EnumCandidateKeys Enumerates a list of all candidate primary keys in the database, which can be referenced by a foreign key.
Öffentliche Methode EnumDatabasePermissions() Enumerates a list of all permissions in the database.
Öffentliche Methode EnumDatabasePermissions(String) Enumerates a list of permissions in the database for the specified user.
Öffentliche Methode EnumDatabasePermissions(DatabasePermissionSet) Enumerates a list of permissions in the database for the specified permission set.
Öffentliche Methode EnumDatabasePermissions(String, DatabasePermissionSet) Enumerates a list of permissions in the database for the specified user and a specified permission set.
Öffentliche Methode EnumLocks() Enumerates a list of all current locks held on the database.
Öffentliche Methode EnumLocks(Int32) Enumerates a list of current locks held on the database for a specified system process ID.
Öffentliche Methode EnumLoginMappings Enumerates a list of SQL Server logins for all the users in the database.
Öffentliche Methode EnumMatchingSPs(String) Enumerates a list of stored procedures that contain the specified string in the definition.
Öffentliche Methode EnumMatchingSPs(String, Boolean) Enumerates a list of stored procedures that contain the specified string in the definition.
Öffentliche Methode EnumObjectPermissions() Enumerates a list of permissions for objects in the database.
Öffentliche Methode EnumObjectPermissions(String) Enumerates a list of permissions for objects in the database that belong to the specified user.
Öffentliche Methode EnumObjectPermissions(ObjectPermissionSet) Enumerates a list of permissions for objects in the database limited to the specified permission set.
Öffentliche Methode EnumObjectPermissions(String, ObjectPermissionSet) Enumerates a list of permissions for objects in the database that belong to the specified user and limited to the specified permission set.
Öffentliche Methode EnumObjects() Enumerates a list of objects in the database.
Öffentliche Methode EnumObjects(DatabaseObjectTypes) Enumerates a list of objects in the database.
Öffentliche Methode EnumObjects(DatabaseObjectTypes, SortOrder) Enumerates a list of objects in the database.
Öffentliche Methode EnumTransactions() Enumerates a list of open transactions on the database.
Öffentliche Methode EnumTransactions(TransactionTypes) Enumerates a list of open transactions of a specified type on the database.
Öffentliche Methode EnumWindowsGroups() Enumerates a list of Windows groups.
Öffentliche Methode EnumWindowsGroups(String) Enumerates a list of Windows groups for a specified group.
Öffentliche Methode Equals (Geerbt von Object.)
Öffentliche Methode ExecuteNonQuery(StringCollection) Executes a batch in the context of the database where there are no results returned.
Öffentliche Methode ExecuteNonQuery(String) Executes a statement in the context of the database where there are no results returned.
Öffentliche Methode ExecuteNonQuery(StringCollection, ExecutionTypes) Runs a collection of batches in the context of the database where there are no results returned for the specified execution type only.
Öffentliche Methode ExecuteNonQuery(String, ExecutionTypes) Executes a batch in the context of the database where there are no results returned for the specified execution type only.
Öffentliche Methode ExecuteWithResults(StringCollection) Executes a batch in the context of the database where there are results returned.
Öffentliche Methode ExecuteWithResults(String) Executes a collection of batches in the context of the database where there are results returned.
Geschützte Methode FormatSqlVariant Formats an object as SqlVariant type. (Geerbt von SqlSmoObject.)
Geschützte Methode GetContextDB Gets the context database that is associated with this object. (Geerbt von SqlSmoObject.)
Geschützte Methode GetDBName Gets the database name that is associated with the object. (Geerbt von SqlSmoObject.)
Öffentliche Methode GetHashCode (Geerbt von Object.)
Geschützte Methode GetPropValue Gets a property value of the SqlSmoObject object. (Geerbt von SqlSmoObject.)
Geschützte Methode GetPropValueOptional Gets a property value of the SqlSmoObject object. (Geerbt von SqlSmoObject.)
Geschützte Methode GetPropValueOptionalAllowNull Gets a property value of the SqlSmoObject object. (Geerbt von SqlSmoObject.)
Geschützte Methode GetServerObject Gets the server of the SqlSmoObject object. (Geerbt von SqlSmoObject.)
Öffentliche Methode GetTransactionCount() Gets the number of open transactions on the database.
Öffentliche Methode GetTransactionCount(TransactionTypes) Gets the number of open transactions of a specified type on the database.
Öffentliche Methode GetType (Geerbt von Object.)
Öffentliche Methode Grant(DatabasePermissionSet, String) Grants the specified set of permissions to the specified grantee on the database.
Öffentliche Methode Grant(DatabasePermissionSet, array<String[]) Grants the specified set of permissions to the specified grantees on the database.
Öffentliche Methode Grant(DatabasePermissionSet, String, Boolean) Grants access to the specified permission to the grantee and the ability to grant access to other users on the database.
Öffentliche Methode Grant(DatabasePermissionSet, array<String[], Boolean) Grants access to the specified permission to the grantees and the ability to grant access to other users on the database.
Öffentliche Methode Grant(DatabasePermissionSet, String, Boolean, String) Grants the specified set of permissions to the grantee and the ability to grant the set of permissions to other users on the database under an assumed role.
Öffentliche Methode Grant(DatabasePermissionSet, array<String[], Boolean, String) Grants the specified set of permissions to the grantees and the ability to grant the set of permissions to other users on the database under an assumed role.
Öffentliche Methode Initialize() Initializes the object and forces the properties be loaded. (Geerbt von SqlSmoObject.)
Öffentliche Methode Initialize(Boolean) Initializes the object and forces the properties be loaded. (Geerbt von SqlSmoObject.)
Öffentliche Methode IsMember Determines whether the specified group or role belongs to the database.
Geschützte Methode IsObjectInitialized Verifies whether the object has been initialized. (Geerbt von SqlSmoObject.)
Geschützte Methode IsObjectInSpace Verifies whether the object is isolated or connected to the instance of SQL Server. (Geerbt von SqlSmoObject.)
Öffentliche Methode PrefetchObjects() Prefetches database objects.
Öffentliche Methode PrefetchObjects(Type) Prefetches database objects of a specified type.
Öffentliche Methode PrefetchObjects(Type, ScriptingOptions) Prefetches database objects of a specified type with scripting options.
Öffentliche Methode RecalculateSpaceUsage Recalculates space usage.
Öffentliche Methode Refresh Updates the Database object. (Überschreibt ScriptNameObjectBase.Refresh().)
Öffentliche Methode RemoveFullTextCatalogs Removes full-text catalogs from the database.
Öffentliche Methode Rename Renames the database.
Öffentliche Methode Revoke(DatabasePermissionSet, String) Revokes a previously granted set of permissions from a grantee on the database.
Öffentliche Methode Revoke(DatabasePermissionSet, array<String[]) Revokes a previously granted set of permissions from a list of grantees on the database.
Öffentliche Methode Revoke(DatabasePermissionSet, String, Boolean, Boolean) Revokes previously granted permissions from a grantee on the database and any other users to whom the grantee has granted the specified set of permissions. The grantee is also given the ability to revoke the specified set of permissions from other users under an assumed role.
Öffentliche Methode Revoke(DatabasePermissionSet, array<String[], Boolean, Boolean) Revokes previously granted permissions from grantees on the database and any other users to whom the grantees have granted the specified set of permissions. The grantees are also given the ability to revoke the specified set of permissions from other users under an assumed role.
Öffentliche Methode Revoke(DatabasePermissionSet, String, Boolean, Boolean, String) Revokes previously granted permissions from a grantee on the database and any other users to whom the grantee has granted the specified set of permissions. The grantee is also given the ability to revoke the specified set of permissions from other users under an assumed role.
Öffentliche Methode Revoke(DatabasePermissionSet, array<String[], Boolean, Boolean, String) Revokes previously granted permissions from grantees on the database and any other users to whom the grantees have granted the specified set of permissions. The grantees are also given the ability to revoke the specified set of permissions from other users under an assumed role.
Öffentliche Methode Script() Generates a Transact-SQL script that can be used to re-create the database.
Öffentliche Methode Script(ScriptingOptions) Generates a Transact-SQL script that can be used to re-create the database as specified by the script options.
Öffentliche Methode SetDefaultFileGroup Sets the default file group for the database.
Öffentliche Methode SetDefaultFileStreamFileGroup Sets the default filestream group.
Öffentliche Methode SetDefaultFullTextCatalog Sets the default full-text catalog for the database.
Öffentliche Methode SetOffline Sets the database offline.
Öffentliche Methode SetOnline Sets the database online.
Öffentliche Methode SetOwner(String) Sets the database owner.
Öffentliche Methode SetOwner(String, Boolean) Sets the database owner.
Geschützte Methode SetParentImpl Sets the parent of the SqlSmoObject to the newParent parameter. (Geerbt von SqlSmoObject.)
Öffentliche Methode SetSnapshotIsolation Sets the snapshot isolation level.
Öffentliche Methode Shrink Shrinks the database.
Öffentliche Methode ToString Returns a String that represents the referenced object. (Geerbt von SqlSmoObject.)
Öffentliche Methode TruncateLog Truncates the database log.
Öffentliche Methode UpdateIndexStatistics Updates index statistics.
Öffentliche Methode Validate Validates the state of an object. (Geerbt von SmoObjectBase.)
Öffentliche Methode ValidateAllPlanGuides() Verifies the validity of the execution plans associated with the database.
Öffentliche Methode ValidateAllPlanGuides(DataTable%) Verifies the validity of the execution plans associated with the database and returns validation report.

Zum Anfang

Ereignisse

  Name Beschreibung
Öffentliches Ereignis PropertyChanged Represents the event that occurs when a property is changed. (Geerbt von SqlSmoObject.)
Öffentliches Ereignis PropertyMetadataChanged Represents the event that occurs when property metadata changes. (Geerbt von SqlSmoObject.)

Zum Anfang

Explizite Schnittstellenimplementierungen

  Name Beschreibung
Explizite SchnittstellenimplementierungPrivate Methode IAlienObject.Discover Discovers any dependencies. Verweisen Sie nicht direkt im Code auf dieses Element. Unterstützt die SQL Server-Infrastruktur. (Geerbt von SqlSmoObject.)
Explizite SchnittstellenimplementierungPrivate Methode IAlienObject.GetDomainRoot Returns the root of the domain. (Geerbt von SqlSmoObject.)
Explizite SchnittstellenimplementierungPrivate Methode IAlienObject.GetParent Gets the parent of this object. Verweisen Sie nicht direkt im Code auf dieses Element. Unterstützt die SQL Server-Infrastruktur. (Geerbt von SqlSmoObject.)
Explizite SchnittstellenimplementierungPrivate Methode IAlienObject.GetPropertyType Gets the type of the specified property. (Geerbt von SqlSmoObject.)
Explizite SchnittstellenimplementierungPrivate Methode IAlienObject.GetPropertyValue Gets the value of the specified property. (Geerbt von SqlSmoObject.)
Explizite SchnittstellenimplementierungPrivate Methode IAlienObject.GetUrn Gets the Unified Resource Name (URN) of the object. Verweisen Sie nicht direkt im Code auf dieses Element. Unterstützt die SQL Server-Infrastruktur. (Geerbt von SqlSmoObject.)
Explizite SchnittstellenimplementierungPrivate Methode IAlienObject.Resolve Gets the instance that contains the information about the object from the Unified Resource Name (URN) of the object. (Geerbt von SqlSmoObject.)
Explizite SchnittstellenimplementierungPrivate Methode IAlienObject.SetObjectState Sets the object state to the specified SfcObjectState value. (Geerbt von SqlSmoObject.)
Explizite SchnittstellenimplementierungPrivate Methode IAlienObject.SetPropertyValue Sets the property value. (Geerbt von SqlSmoObject.)
Explizite SchnittstellenimplementierungPrivate Methode ISfcPropertyProvider.GetPropertySet Gets the interface reference to the set of properties of this object. (Geerbt von SqlSmoObject.)
Explizite SchnittstellenimplementierungPrivate Eigenschaft ISfcSupportsDesignMode.IsDesignMode Gets a value that indicates whether the object supports design mode. Nur für Informationszwecke identifiziert. Nicht unterstützt. Zukünftige Kompatibilität wird nicht sichergestellt.

Zum Anfang

Hinweise

The Database class represents databases, either system or user-defined, on the instance of SQL Server. The Server class is the parent of the Database class.

By using the Database class, you can do the following:

  • Create a new database or drop an existing database.

  • Register the database in the Active Directory service.

  • Reference database objects in collections, such as tables, users, and triggers.

  • Set up database mirroring.

  • Create a master database key.

  • Set up a full-text search catalog.

  • Check data, allocations, catalogs, and tables.

  • Issue a checkpoint.

  • Grant, revoke, and deny permissions to users on the database.

  • Run Transact-SQL statements.

  • Enumerate database information, such as locks or object permissions.

  • Remove the backup history.

  • Monitor the number of transactions.

  • Set the database offline or online.

  • Change the owner of the database.

  • Update statistics.

  • Shrink the database.

  • Truncate the log.

  • Script the database.

To get Database object properties, a login must be a member of the public fixed server role and the user mapped to this login in the database must be a member of the public database role.

To set Database object properties and run the Alter method, users must have ALTER permission on the database, or be a member of the db_owner fixed database role.

To create a database, users must have CREATE DATABASE, CREATE ANY DATABASE, or ALTER ANY DATABASE permission on the parent server.

To drop a database, users must have CONTROL permission on the database, or be a member of the db_owner fixed database role.

To grant, revoke, or deny other users permission on the database, users must have CONTROL permission on the database or be a member of the db_owner fixed database role.

Thread Safety

Alle öffentlichen, statischen Elemente dieses Typs (Shared in Microsoft Visual Basic) sind für Vorgänge mit mehreren Threads sicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.

Beispiele

VB

'Connect to the local, default instance of SQL Server.
Dim srv As Server
srv = New Server
'Define a Database object variable by supplying the server and the database name arguments in the constructor.
Dim db As Database
db = New Database(srv, "Test_SMO_Database")
'Create the database on the instance of SQL Server.
db.Create()
'Reference the database and display the date when it was created.
db = srv.Databases("Test_SMO_Database")
Console.WriteLine(db.CreateDate)
'Remove the database.
db.Drop()

PowerShell

$srv = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)")
$db = New-Object Microsoft.SqlServer.Management.Smo.Database($srv, "Test_SMO_Database")
$db.Create()
Write-Host $db.CreateDate
$db.Drop()

Threadsicherheit

Alle öffentlichen static (Shared in Visual Basic)-Elemente dieses Typs sind Threadsicher. Für Instanzelemente wird die Threadsicherheit nicht gewährleistet.

Siehe auch

Verweis

Microsoft.SqlServer.Management.Smo-Namespace

Andere Ressourcen

Arbeiten mit Datenbankobjekten

Erstellen, Ändern und Löschen von Datenbanken

CREATE DATABASE (Transact-SQL)