Compartir a través de


Clase Database

Represents an SQL Server database.

Jerarquía de herencia

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

Espacio de nombres:  Microsoft.SqlServer.Management.Smo
Ensamblado:  Microsoft.SqlServer.Smo (en Microsoft.SqlServer.Smo.dll)

Sintaxis

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

El tipo Database expone los siguientes miembros.

Constructores

  Nombre Descripción
Método público Database() Initializes a new instance of the Database class.
Método público Database(Server, String) Initializes a new instance of the Database class on the specified server and with the specified name.

Arriba

Propiedades

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

Arriba

Métodos

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

Arriba

Eventos

  Nombre Descripción
Evento público PropertyChanged Represents the event that occurs when a property is changed. (Se hereda de SqlSmoObject.)
Evento público PropertyMetadataChanged Represents the event that occurs when property metadata changes. (Se hereda de SqlSmoObject.)

Arriba

Implementaciones de interfaces explícitas

  Nombre Descripción
Implementación de interfaces explícitasMétodo privado IAlienObject.Discover Discovers any dependencies. No haga referencia directamente a este miembro en el código. Admite la infraestructura de SQL Server. (Se hereda de SqlSmoObject.)
Implementación de interfaces explícitasMétodo privado IAlienObject.GetDomainRoot Returns the root of the domain. (Se hereda de SqlSmoObject.)
Implementación de interfaces explícitasMétodo privado IAlienObject.GetParent Gets the parent of this object. No haga referencia directamente a este miembro en el código. Admite la infraestructura de SQL Server. (Se hereda de SqlSmoObject.)
Implementación de interfaces explícitasMétodo privado IAlienObject.GetPropertyType Gets the type of the specified property. (Se hereda de SqlSmoObject.)
Implementación de interfaces explícitasMétodo privado IAlienObject.GetPropertyValue Gets the value of the specified property. (Se hereda de SqlSmoObject.)
Implementación de interfaces explícitasMétodo privado IAlienObject.GetUrn Gets the Unified Resource Name (URN) of the object. No haga referencia directamente a este miembro en el código. Admite la infraestructura de SQL Server. (Se hereda de SqlSmoObject.)
Implementación de interfaces explícitasMétodo privado IAlienObject.Resolve Gets the instance that contains the information about the object from the Unified Resource Name (URN) of the object. (Se hereda de SqlSmoObject.)
Implementación de interfaces explícitasMétodo privado IAlienObject.SetObjectState Sets the object state to the specified SfcObjectState value. (Se hereda de SqlSmoObject.)
Implementación de interfaces explícitasMétodo privado IAlienObject.SetPropertyValue Sets the property value. (Se hereda de SqlSmoObject.)
Implementación de interfaces explícitasMétodo privado ISfcPropertyProvider.GetPropertySet Gets the interface reference to the set of properties of this object. (Se hereda de SqlSmoObject.)
Implementación de interfaces explícitasPropiedad privada ISfcSupportsDesignMode.IsDesignMode Gets a value that indicates whether the object supports design mode. Solamente se identifica con fines informativos. No compatible. La compatibilidad con versiones posteriores no está garantizada.

Arriba

Comentarios

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

Todos los miembros estáticos (compartidos en Microsoft Visual Basic) públicos de este tipo son seguros para operaciones multiproceso. No se garantiza que los miembros de instancia sean seguros para subprocesos.

Ejemplos

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

Seguridad para subprocesos

Cualquier miembro público static (Shared en Visual Basic) de este tipo es seguro para subprocesos. No se garantiza que los miembros de instancia sean seguros para subprocesos.

Vea también

Referencia

Espacio de nombres Microsoft.SqlServer.Management.Smo

Otros recursos

Trabajar con objetos de bases de datos

Crear, modificar y eliminar bases de datos

CREATE DATABASE (Transact-SQL)