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
此型別的任何公用靜態 (在 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()
執行緒安全性
這個型別的任何公用 static (在 Visual Basic 中為 Shared) 成員都是執行緒安全的。並不是所有的執行個體成員都保證可以用於所有的執行緒。
請參閱
參考
Microsoft.SqlServer.Management.Smo 命名空間