恢复模式 (SQL Server)Recovery Models (SQL Server)

适用对象:是SQL Server 否Azure SQL 数据库 否Azure Synapse Analytics (SQL DW) 否并行数据仓库 APPLIES TO: yesSQL Server noAzure SQL Database noAzure Synapse Analytics (SQL DW) noParallel Data Warehouse

SQL ServerSQL Server 备份和还原操作发生在数据库的恢复模式的上下文中。backup and restore operations occur within the context of the recovery model of the database. 恢复模式旨在控制事务日志维护。Recovery models are designed to control transaction log maintenance. “恢复模式” 是一种数据库属性,它控制如何记录事务,事务日志是否需要(以及允许)进行备份,以及可以使用哪些类型的还原操作。A recovery model is a database property that controls how transactions are logged, whether the transaction log requires (and allows) backing up, and what kinds of restore operations are available. 有三种恢复模式:简单恢复模式、完整恢复模式和大容量日志恢复模式。Three recovery models exist: simple, full, and bulk-logged. 通常,数据库使用完整恢复模式或简单恢复模式。Typically, a database uses the full recovery model or simple recovery model. 数据库可以随时切换为其他恢复模式。A database can be switched to another recovery model at any time.

本主题内容:In this Topic:

恢复模式概述Recovery Model Overview

下表概述了这三种恢复模式。The following table summarizes the three recovery models.

恢复模式Recovery model 说明Description 工作丢失的风险Work loss exposure 能否恢复到时点?Recover to point in time?
简单Simple 无日志备份。No log backups.

自动回收日志空间以减少空间需求,实际上不再需要管理事务日志空间。Automatically reclaims log space to keep space requirements small, essentially eliminating the need to manage the transaction log space. 有关简单恢复模式下数据库备份的详细信息,请参阅完整数据库备份 (SQL Server)For information about database backups under the simple recovery model, see Full Database Backups (SQL Server).

简单恢复模式不支持要求事务日志备份的操作。Operations that require transaction log backups are not supported by the simple recovery model. 在简单恢复模式中不能使用以下功能:The following features cannot be used in simple recovery mode:

-日志传送-Log shipping

-AlwaysOn 或数据库镜像-Always On or Database mirroring

-没有数据丢失的介质恢复-Media recovery without data loss

-时点还原-Point-in-time restores
最新备份之后的更改不受保护。Changes since the most recent backup are unprotected. 在发生灾难时,这些更改必须重做。In the event of a disaster, those changes must be redone. 只能恢复到备份的结尾。Can recover only to the end of a backup. 有关详细信息,请参阅完整数据库还原(简单恢复模式)For more information, see Complete Database Restores (Simple Recovery Model).

有关简单恢复模式的更多深入说明,请参阅由 SQL Server 简单恢复模式 人员提供的 SQL Server 简单恢复模式For a more in depth explanation of the Simple recovery model, see SQL Server Simple Recovery Model provided by the folks at MSSQLTips!
完整Full 需要日志备份。Requires log backups.

数据文件丢失或损坏不会导致丢失工作。No work is lost due to a lost or damaged data file.

可以恢复到任意时点(例如应用程序或用户错误之前)。Can recover to an arbitrary point in time (for example, prior to application or user error). 有关完整恢复模式下的数据库备份的信息,请参阅 完整数据库备份 (SQL Server)完整数据库还原(完整恢复模式)For information about database backups under the full recovery model, see Full Database Backups (SQL Server) and Complete Database Restores (Full Recovery Model).
正常情况下没有。Normally none.

如果日志尾部损坏,则必须重做自最新日志备份之后所做的更改。If the tail of the log is damaged, changes since the most recent log backup must be redone.
如果备份在接近特定的时点完成,则可以恢复到该时点。Can recover to a specific point in time, assuming that your backups are complete up to that point in time. 有关使用日志备份还原到故障点的信息,请参阅将 SQL Server 数据库还原到某个时间点(完整恢复模式)For information about using log backups to restore to the point of failure, see Restore a SQL Server Database to a Point in Time (Full Recovery Model).

注意:如果有两个或更多必须在逻辑上保持一致的完整恢复模式数据库,则最好执行特殊步骤,以确保这些数据库的可恢复性。Note: If you have two or more full-recovery-model databases that must be logically consistent, you may have to implement special procedures to make sure the recoverability of these databases. 有关详细信息,请参阅 包含标记的事务的相关数据库的恢复For more information, see Recovery of Related Databases That Contain Marked Transaction.
大容量日志Bulk logged 需要日志备份。Requires log backups.

是完整恢复模式的附加模式,允许执行高性能的大容量复制操作。An adjunct of the full recovery model that permits high-performance bulk copy operations.

通过使用最小方式记录大多数大容量操作,减少日志空间使用量。Reduces log space usage by using minimal logging for most bulk operations. 有关尽量减少日志量的操作的信息,请参阅 事务日志 (SQL Server)For information about operations that can be minimally logged, see The Transaction Log (SQL Server).

日志备份可能很大,因为日志备份中捕获了最低限度记录的操作。Log backups may be of a significant size because the minimally-logged operations are captured in the log backup. 有关大容量日志恢复模式下的数据库备份的信息,请参阅完整数据库备份 (SQL Server)完整数据库还原(完整恢复模式)For information about database backups under the bulk-logged recovery model, see Full Database Backups (SQL Server) and Complete Database Restores (Full Recovery Model).
如果在最新日志备份后发生日志损坏或执行大容量日志记录操作,则必须重做自该上次备份之后所做的更改。If the log is damaged or bulk-logged operations occurred since the most recent log backup, changes since that last backup must be redone.

否则不丢失任何工作。Otherwise, no work is lost.
可以恢复到任何备份的结尾。Can recover to the end of any backup. 不支持时点恢复。Point-in-time recovery is not supported.

相关任务Related Tasks

另请参阅See Also

backupset (Transact-SQL) backupset (Transact-SQL)
sys.databases (Transact-SQL) sys.databases (Transact-SQL)
ALTER DATABASE SET 选项 (Transact-SQL) ALTER DATABASE SET Options (Transact-SQL)
SQL Server 数据库的备份和还原 Back Up and Restore of SQL Server Databases
事务日志 (SQL Server) The Transaction Log (SQL Server)
自动执行管理任务(SQL Server 代理) Automated Administration Tasks (SQL Server Agent)
还原和恢复概述 (SQL Server)Restore and Recovery Overview (SQL Server)