[英]Configuring default values for initial size and auto-growth size for database when publishing dacpac (SSDT Database project)
[英]Set initial growth size for database using PowerShell
我目前正在使用PowerShell創建數據庫,如下所示:
$db = New-Object Microsoft.SqlServer.Management.Smo.Database($server, $database)
$db.Collation = "...";
...
$db.Create()
現在我的問題是:如何設置數據和日志文件的初始大小以及它們各自的增長大小?
到目前為止,我嘗試了以下方法:
foreach ($fg in $db.FileGroups) {
foreach($f in $fg) {
$f.Size = $initialDataFileSizeInKB
$f.Growth = $dataFileGrowthInKB
$f.GrowthType = [Microsoft.SqlServer.Management.Smo.FileGrowthType]::KB
}
}
}
foreach($lf in $db.LogFiles) {
$lf.Size = $initialLogFileSizeInKB
$lf.Growth = $logFileGrowthInKB
$lf.GrowthType = [Microsoft.SqlServer.Management.Smo.FileGrowthType]::KB
}
但是,這不起作用-問題似乎是還沒有文件或日志文件。 如何設置默認值?
對於Growth和GrowthType,修改單個文件。
foreach ($fg in $db.FileGroups) {
foreach ($f in $fg.Files) {
$f.Growth = $dataFileGrowthInKB
$f.GrowthType = 'KB'
$f.Alter()
}
}
我不確定要修改初始大小。
您是否嘗試過將其設置為數據庫創建的一部分?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.