Partager via


Classe Database

Represents an SQL Server database.

Hiérarchie d'héritage

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

Espace de noms :  Microsoft.SqlServer.Management.Smo
Assembly :  Microsoft.SqlServer.Smo (en Microsoft.SqlServer.Smo.dll)

Syntaxe

'Déclaration
<PhysicalFacetAttribute> _
<EvaluationModeAttribute(AutomatedPolicyEvaluationMode.CheckOnSchedule)> _
Public NotInheritable Class Database _
    Inherits ScriptNameObjectBase _
    Implements ICreatable, IAlterable, IDroppable, IRenamable,  _
    IExtendedProperties, IScriptable, IDatabaseOptions, IDmfFacet, ISfcSupportsDesignMode
'Utilisation
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

Le type Database expose les membres suivants.

Constructeurs

  Nom Description
Méthode publique Database() Initializes a new instance of the Database class.
Méthode publique Database(Server, String) Initializes a new instance of the Database class on the specified server and with the specified name.

Haut de la page

Propriétés

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

Haut de la page

Méthodes

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

Haut de la page

Événements

  Nom Description
Événement public PropertyChanged Represents the event that occurs when a property is changed. (hérité de SqlSmoObject.)
Événement public PropertyMetadataChanged Represents the event that occurs when property metadata changes. (hérité de SqlSmoObject.)

Haut de la page

Implémentations d'interfaces explicites

  Nom Description
Implémentation d'interface expliciteMéthode privée IAlienObject.Discover Discovers any dependencies. Ne faites pas directement référence à ce membre dans votre code. Il prend en charge l'infrastructure SQL Server. (hérité de SqlSmoObject.)
Implémentation d'interface expliciteMéthode privée IAlienObject.GetDomainRoot Returns the root of the domain. (hérité de SqlSmoObject.)
Implémentation d'interface expliciteMéthode privée IAlienObject.GetParent Gets the parent of this object. Ne faites pas directement référence à ce membre dans votre code. Il prend en charge l'infrastructure SQL Server. (hérité de SqlSmoObject.)
Implémentation d'interface expliciteMéthode privée IAlienObject.GetPropertyType Gets the type of the specified property. (hérité de SqlSmoObject.)
Implémentation d'interface expliciteMéthode privée IAlienObject.GetPropertyValue Gets the value of the specified property. (hérité de SqlSmoObject.)
Implémentation d'interface expliciteMéthode privée IAlienObject.GetUrn Gets the Unified Resource Name (URN) of the object. Ne faites pas directement référence à ce membre dans votre code. Il prend en charge l'infrastructure SQL Server. (hérité de SqlSmoObject.)
Implémentation d'interface expliciteMéthode privée IAlienObject.Resolve Gets the instance that contains the information about the object from the Unified Resource Name (URN) of the object. (hérité de SqlSmoObject.)
Implémentation d'interface expliciteMéthode privée IAlienObject.SetObjectState Sets the object state to the specified SfcObjectState value. (hérité de SqlSmoObject.)
Implémentation d'interface expliciteMéthode privée IAlienObject.SetPropertyValue Sets the property value. (hérité de SqlSmoObject.)
Implémentation d'interface expliciteMéthode privée ISfcPropertyProvider.GetPropertySet Gets the interface reference to the set of properties of this object. (hérité de SqlSmoObject.)
Implémentation d'interface explicitePropriété privée ISfcSupportsDesignMode.IsDesignMode Gets a value that indicates whether the object supports design mode. Identifié à titre d'information uniquement. Non pris en charge. La compatibilité future n'est pas garantie.

Haut de la page

Notes

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

Tout membre statique public (Partagé dans Microsoft Visual Basic) de ce type est sûr dans le cadre des opérations à plusieurs threads. Tous les membres de l'instance ne sont pas garantis comme étant thread-safe.

Exemples

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

Sécurité des threads

Tous les membres publics static (Shared dans Visual Basic) de ce type sont thread-safe. Tous les membres de l'instance ne sont pas garantis comme étant thread-safe.

Voir aussi

Référence

Espace de noms Microsoft.SqlServer.Management.Smo

Autres ressources

Utilisation des objets de base de données

Création, modification et suppression de bases de données

CREATE DATABASE (Transact-SQL)