Database Resource
Synopsis
Manages SQL Server databases, including creation, configuration options, ANSI settings, performance options, and availability features.
Type
Capabilities
- Get
- Set
- Delete
- Export
Properties
Connection properties
serverInstance
SQL Server instance name.
connectUsername
Username for SQL authentication.
connectPassword
Password for SQL authentication.
Database properties
name
Name of the database.
collation
Database collation. Defaults to server collation.
compatibilityLevel
Compatibility level (Version90 through Version160).
recoveryModel
Recovery model: Simple, Full, or BulkLogged.
owner
Login name of database owner.
readOnly
Whether the database is read-only.
userAccess
User access: Multi, Single, or Restricted.
pageVerify
Page verification: None, TornPageDetection, or Checksum.
containmentType
Containment: None or Partial.
File properties (write-only, used during creation)
primaryFilePath
Path to primary data file (.mdf).
logFilePath
Path to log file (.ldf).
primaryFileSize
Initial primary file size in MB.
logFileSize
Initial log file size in MB.
primaryFileGrowth
Primary file growth amount in MB.
logFileGrowth
Log file growth amount in MB.
ANSI settings
ansiNullDefault
Whether ANSI NULL default is enabled.
ansiNullsEnabled
Whether ANSI NULLs are enabled.
ansiPaddingEnabled
Whether ANSI padding is enabled.
ansiWarningsEnabled
Whether ANSI warnings are enabled.
arithmeticAbortEnabled
Whether arithmetic abort is enabled.
concatenateNullYieldsNull
Whether concatenating null yields null.
numericRoundAbortEnabled
Whether numeric round-abort is enabled.
quotedIdentifiersEnabled
Whether quoted identifiers are enabled.
Performance and behavior settings
autoClose
Auto-close when last user exits.
autoShrink
Automatically shrink database.
autoCreateStatisticsEnabled
Automatic statistics creation.
autoUpdateStatisticsEnabled
Automatic statistics update.
autoUpdateStatisticsAsync
Async statistics update.
closeCursorsOnCommitEnabled
Close cursors on transaction commit.
localCursorsDefault
Default to local cursor scope.
nestedTriggersEnabled
Allow nested triggers.
recursiveTriggersEnabled
Allow recursive triggers.
trustworthy
Database is trustworthy.
databaseOwnershipChaining
Cross-database ownership chaining.
dateCorrelationOptimization
Date correlation optimization.
brokerEnabled
Service Broker enabled.
encryptionEnabled
Transparent data encryption.
isParameterizationForced
Forced parameterization.
isReadCommittedSnapshotOn
READ_COMMITTED_SNAPSHOT isolation.
isFullTextEnabled
Full-text indexing.
targetRecoveryTime
Target recovery time in seconds.
delayedDurabilityEnabled
Delayed durability.
acceleratedRecoveryEnabled
Accelerated database recovery.
Read-only properties
id
Database ID.
createDate
Creation date.
size
Current size in MB.
spaceAvailable
Space available in KB.
dataSpaceUsage
Data space usage in KB.
indexSpaceUsage
Index space usage in KB.
activeConnections
Number of active connections.
lastBackupDate
Date of last full backup.
lastDifferentialBackupDate
Date of last differential backup.
lastLogBackupDate
Date of last log backup.
status
Database status.
isSystemObject
Whether it is a system database.
isAccessible
Whether the database is accessible.
isUpdateable
Whether the database is updateable.
isDatabaseSnapshot
Whether it is a database snapshot.
isMirroringEnabled
Whether mirroring is enabled.
availabilityGroupName
Availability group name.
caseSensitive
Whether the database is case-sensitive.
primaryFilePathActual
Actual path to primary file.
defaultFileGroup
Default file group name.
DSC properties
_exist
Whether the database should exist. Defaults to true.
Examples
Example 1 — Get a database
Example 2 — Create a database
Example 3 — Configuration document
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
resources:
- name: Application database
type: OpenDsc.SqlServer/Database
properties:
serverInstance: "."
name: AppDb
recoveryModel: Full
autoShrink: false
autoCreateStatisticsEnabled: true
autoUpdateStatisticsEnabled: true
Exit codes
| Code | Description |
|---|---|
| 0 | Success |
| 1 | Error |
| 2 | Invalid JSON |
| 3 | Invalid argument |
| 4 | Unauthorized access |
| 5 | Invalid operation |