DBCC SHRINKLOG (平行資料倉儲)DBCC SHRINKLOG (Parallel Data Warehouse)

適用於: 否SQL Server 否Azure SQL Database 否Azure SQL 資料倉儲 是平行處理資料倉儲 APPLIES TO: noSQL Server noAzure SQL Database noAzure SQL Data Warehouse yesParallel Data Warehouse

「跨設備」 降低目前 平行處理資料倉儲Parallel Data Warehouse 資料庫的交易記錄大小。Reduces the size of the transaction log across the appliance for the current 平行處理資料倉儲Parallel Data Warehouse database. 資料重組是為了壓縮交易記錄。The data is defragmented in order to shrink the transaction log. 資料庫交易記錄可能會隨著時間變得分散和沒有效率。Over time, the database transaction log can become fragmented and inefficient. 使用 DBCC SHRINKLOG 可減少資料分散程度,並縮減記錄大小。Use DBCC SHRINKLOG to reduce fragmentation and reduce the log size.

主題連結圖示 Transact-SQL 語法慣例 (Transact-SQL)Topic link icon Transact-SQL Syntax Conventions (Transact-SQL)

語法Syntax

DBCC SHRINKLOG   
    [ ( SIZE = { target_size [ MB | GB | TB ]  } | DEFAULT ) ]   
    [ WITH NO_INFOMSGS ]   
[;]  

引數Arguments

SIZE = { target_size [ MB | GB | TB ] } | DEFAULTSIZE = { target_size [ MB | GB | TB ] } | DEFAULT.
target_size 是 DBCC SHRINKLOG 完成後期望的交易記錄大小 (跨所有計算節點)。target_size is the desired size for the transaction log, across all the Compute nodes, after DBCC SHRINKLOG completes. 其為大於 0 的整數。It is an integer greater than 0.
記錄大小的測量單位是 MB、GB 或 TB。The log size is measured in megabytes (MB), gigabytes (GB), or terabytes (TB). 它是所有計算節點上的交易記錄合併的大小。It is the combined size of the transaction log on all of the Compute nodes.
根據預設,DBCC SHRINKLOG 會將交易記錄縮減為儲存在資料庫中繼資料中的記錄大小。By default, DBCC SHRINKLOG reduces the transaction log to the log size stored in the metadata for the database. 中繼資料的記錄大小是由 CREATE DATABASE (Azure SQL Data Warehouse) or ALTER DATABASE (Azure SQL Data Warehouse) 中的 LOG_SIZE 參數所決定。The log size in the metadata is determined by the LOG_SIZE parameter in CREATE DATABASE (Azure SQL Data Warehouse) or ALTER DATABASE (Azure SQL Data Warehouse). 指定 SIZE=DEFAULT 或省略 SIZE 子句時,DBCC SHRINKLOG 會將交易記錄大小縮減至預設大小。DBCC SHRINKLOG reduces the transaction log size to the default size when SIZE=DEFAULT is specified, or when the SIZE clause is omitted.

WITH NO_INFOMSGSWITH NO_INFOMSGS
DBCC SHRINKLOG 結果中不會顯示資訊訊息。Informational messages are not displayed in the DBCC SHRINKLOG results.

權限Permissions

需要 ALTER SERVER STATE 權限。Requires ALTER SERVER STATE permission.

一般備註General Remarks

DBCC SHRINKLOG 不會變更儲存在資料庫中繼資料的記錄大小。DBCC SHRINKLOG does not change the log size stored in the metadata for the database. 中繼資料會繼續包含在 CREATE DATABASE 或 ALTER DATABASE 陳述式中指定的 LOG_SIZE 參數。The metadata continues to contain the LOG_SIZE parameter that was specified in CREATE DATABASE or ALTER DATABASE statement.

範例Examples

A.A. 將交易記錄縮減至 CREATE DATABASE 指定的原始大小。Shrink the transaction log to the original size specified by CREATE DATABASE.

假設位址資料庫建立時設定的交易記錄大小是 100 MB。Suppose the transaction log for the Addresses database was set to 100 MB when the Addresses database was created. 也就是說,位址資料庫的 CREATE DATABASE 陳述式中含有 LOG_SIZE = 100 MB。That is, the CREATE DATABASE statement for Addresses had LOG_SIZE = 100 MB. 現在,假設記錄已成長至 150 MB,而您想將記錄壓縮回 100 MB。Now, suppose the log has grown to 150 MB and you want to shrink it back to 100 MB.

下方的各個陳述式會嘗試將位址資料庫的交易記錄壓縮至預設大小 100 MB。Each of the following statements will attempt to shrink the transaction log for the Addresses database to the default size of 100 MB. 如果將記錄壓縮至 100 MB 會導致資料遺失,DBCC SHRINKLOG 會盡可能將記錄壓縮到沒有資料遺失的最小大小 (大於 100 MB)。If shrinking the log to 100 MB will cause data loss, DBCC SHRINKLOG will shrink the log to the smallest size possible, greater than 100 MB, without losing data.

USE Addresses;  
DBCC SHRINKLOG ( SIZE = 100 MB );  
DBCC SHRINKLOG ( SIZE = DEFAULT );  
DBCC SHRINKLOG;