Поделиться через


Класс Database

Represents an SQL Server database.

Иерархия наследования

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

Пространство имен:  Microsoft.SqlServer.Management.Smo
Сборка:  Microsoft.SqlServer.Smo (в Microsoft.SqlServer.Smo.dll)

Синтаксис

'Декларация
<PhysicalFacetAttribute> _
<EvaluationModeAttribute(AutomatedPolicyEvaluationMode.CheckOnSchedule)> _
Public NotInheritable Class Database _
    Inherits ScriptNameObjectBase _
    Implements ICreatable, IAlterable, IDroppable, IRenamable,  _
    IExtendedProperties, IScriptable, IDatabaseOptions, IDmfFacet, ISfcSupportsDesignMode
'Применение
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

Тип Database обеспечивает доступ к следующим элементам.

Конструкторы

  Имя Описание
Открытый метод Database() Initializes a new instance of the Database class.
Открытый метод Database(Server, String) Initializes a new instance of the Database class on the specified server and with the specified name.

В начало

Свойства

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

В начало

Методы

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

В начало

События

  Имя Описание
Открытое событие PropertyChanged Represents the event that occurs when a property is changed. (Производный от SqlSmoObject.)
Открытое событие PropertyMetadataChanged Represents the event that occurs when property metadata changes. (Производный от SqlSmoObject.)

В начало

Явные реализации интерфейса

  Имя Описание
Явная реализация интерфейсаЗакрытый метод IAlienObject.Discover Discovers any dependencies. Не ссылайтесь на этот элемент непосредственно из кода. Он поддерживает работу инфраструктуры SQL Server. (Производный от SqlSmoObject.)
Явная реализация интерфейсаЗакрытый метод IAlienObject.GetDomainRoot Returns the root of the domain. (Производный от SqlSmoObject.)
Явная реализация интерфейсаЗакрытый метод IAlienObject.GetParent Gets the parent of this object. Не ссылайтесь на этот элемент непосредственно из кода. Он поддерживает работу инфраструктуры SQL Server. (Производный от SqlSmoObject.)
Явная реализация интерфейсаЗакрытый метод IAlienObject.GetPropertyType Gets the type of the specified property. (Производный от SqlSmoObject.)
Явная реализация интерфейсаЗакрытый метод IAlienObject.GetPropertyValue Gets the value of the specified property. (Производный от SqlSmoObject.)
Явная реализация интерфейсаЗакрытый метод IAlienObject.GetUrn Gets the Unified Resource Name (URN) of the object. Не ссылайтесь на этот элемент непосредственно из кода. Он поддерживает работу инфраструктуры SQL Server. (Производный от SqlSmoObject.)
Явная реализация интерфейсаЗакрытый метод IAlienObject.Resolve Gets the instance that contains the information about the object from the Unified Resource Name (URN) of the object. (Производный от SqlSmoObject.)
Явная реализация интерфейсаЗакрытый метод IAlienObject.SetObjectState Sets the object state to the specified SfcObjectState value. (Производный от SqlSmoObject.)
Явная реализация интерфейсаЗакрытый метод IAlienObject.SetPropertyValue Sets the property value. (Производный от SqlSmoObject.)
Явная реализация интерфейсаЗакрытый метод ISfcPropertyProvider.GetPropertySet Gets the interface reference to the set of properties of this object. (Производный от SqlSmoObject.)
Явная реализация интерфейсаЗакрытое свойство ISfcSupportsDesignMode.IsDesignMode Gets a value that indicates whether the object supports design mode. Указано только в ознакомительных целях. Не поддерживается. Совместимость с будущими версиями не гарантируется.

В начало

Замечания

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

Все общие статические члены этого типа (Shared в Microsoft Visual Basic) можно использовать в многопоточных операциях. Потокобезопасная работа с членами экземпляров типа не гарантируется.

Примеры

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()

Безопасность многопоточности

Любые открытые статический (Shared в Visual Basic) элементы этого типа потокобезопасны. Потокобезопасность с элементами экземпляров не гарантируется.

См. также

Справочник

Пространство имен Microsoft.SqlServer.Management.Smo

Другие ресурсы

Работа с объектами базы данных

Создание, изменение и удаление баз данных

CREATE DATABASE (Transact-SQL)