Database

SMO klasse for en database.

Eksempel

En databases attributter kan læses med dette script (PowerShell):

[System.Reflection.Assembly]::LoadWithPartialName( "Microsoft.SqlServer.Smo" ) | out-null

$server = New-Object "Microsoft.SqlServer.Management.Smo.Server" "."
$server.Databases[ "AdventureWorks" ]

Resultatet kan se således ud:

ExtendedProperties                 : {MS_Description}
DatabaseOptions                    : Microsoft.SqlServer.Management.Smo.DatabaseOptions
Synonyms                           : {}
Tables                             : {AWBuildVersion, DatabaseLog, dtproperties, ErrorLog...}
StoredProcedures                   : {dt_adduserobject, dt_droppropertiesbyid, dt_dropuserobjectbyid, dt_generateansina
                                     me...}
Assemblies                         : {}
UserDefinedTypes                   : {}
UserDefinedAggregates              : {}
FullTextCatalogs                   : {}
Certificates                       : {}
SymmetricKeys                      : {}
AsymmetricKeys                     : {}
ExtendedStoredProcedures           : {sp_AddFunctionalUnitToComponent, sp_batch_params, sp_bindsession, sp_control_dbma
                                     sterkey_password...}
UserDefinedFunctions               : {ufnGetAccountingEndDate, ufnGetAccountingStartDate, ufnGetContactInformation, ufn
                                     GetDocumentStatusText...}
Views                              : {vEmployee, vEmployeeDepartment, vEmployeeDepartmentHistory, vJobCandidate...}
Users                              : {dbo, guest, INFORMATION_SCHEMA, sys}
Schemas                            : {db_accessadmin, db_backupoperator, db_datareader, db_datawriter...}
Roles                              : {db_accessadmin, db_backupoperator, db_datareader, db_datawriter...}
ApplicationRoles                   : {}
LogFiles                           : {AdventureWorks_Log}
FileGroups                         : {PRIMARY}
Defaults                           : {}
Rules                              : {}
UserDefinedDataTypes               : {AccountNumber, Flag, Name, NameStyle...}
XmlSchemaCollections               : {HRResumeSchemaCollection, AdditionalContactInfoSchemaCollection, ManuInstructions
                                     SchemaCollection, ProductDescriptionSchemaCollection...}
PartitionFunctions                 : {}
PartitionSchemes                   : {}
ActiveDirectory                    : [AdventureWorks]
MasterKey                          :
Triggers                           : {ddlDatabaseTriggerLog}
ServiceBroker                      : Microsoft.SqlServer.Management.Smo.Broker.ServiceBroker
IsVarDecimalStorageFormatEnabled   : False
Parent                             : [TITAN]
ActiveConnections                  : 0
AutoCreateStatisticsEnabled        : True
AutoUpdateStatisticsEnabled        : True
CaseSensitive                      : False
Collation                          : SQL_Latin1_General_CP1_CI_AS
CompatibilityLevel                 : Version90
CreateDate                         : 05-06-2007 21:10:45
DatabaseGuid                       : 5956b629-86df-4000-bac0-52194a773d3b
DatabaseSnapshotBaseName           :
DataSpaceUsage                     : 101320
DboLogin                           : True
DefaultFileGroup                   : PRIMARY
DefaultFullTextCatalog             :
DefaultSchema                      : dbo
ID                                 : 6
IndexSpaceUsage                    : 60352
IsAccessible                       : True
IsDatabaseSnapshot                 : False
IsDatabaseSnapshotBase             : False
IsDbAccessAdmin                    : True
IsDbBackupOperator                 : True
IsDbDatareader                     : True
IsDbDatawriter                     : True
IsDbDdlAdmin                       : True
IsDbDenyDatareader                 : False
IsDbDenyDatawriter                 : False
IsDbOwner                          : True
IsDbSecurityAdmin                  : True
IsFullTextEnabled                  : True
IsMailHost                         : False
IsMirroringEnabled                 : False
IsSystemObject                     : False
IsUpdateable                       : True
LastBackupDate                     : 28-06-2007 23:10:33
LastLogBackupDate                  : 01-01-0001 00:00:00
LogReuseWaitStatus                 : Nothing
MirroringFailoverLogSequenceNumber :
MirroringID                        :
MirroringPartner                   :
MirroringPartnerInstance           :
MirroringRoleSequence              :
MirroringSafetyLevel               : None
MirroringSafetySequence            :
MirroringStatus                    : None
MirroringWitness                   :
MirroringWitnessStatus             : None
Owner                              : TITAN\Niels
PrimaryFilePath                    : C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data
RecoveryForkGuid                   : b935aac8-bb1a-4c10-ad0b-014dfef2fc72
ReplicationOptions                 : 0
ServiceBrokerGuid                  : 572affec-1533-4477-b592-664953032388
Size                               : 165,9375
SpaceAvailable                     : 0
Status                             : Normal
UserName                           : dbo
Version                            : 611
Events                             : Microsoft.SqlServer.Management.Smo.DatabaseEvents
Name                               : AdventureWorks
Urn                                : Server[@Name='TITAN']/Database[@Name='AdventureWorks']
Properties                         : {ActiveConnections, CompatibilityLevel, CreateDate, DataSpaceUsage...}
UserData                           :
State                              : Existing

Niels Grove-Rasmussen Opdateret 18-03-2019 01:25:48.
Ting Ta'r Tid! Hentet 21-12-2024 19:09:55.