SQL Server Database Recovery Models
SQL Server provides three recovery models to control the data protection and transaction log management in a database:
Simple Recovery Model: In this recovery model, the transaction logs are automatically truncated after each transaction checkpoint and don't support point-in-time recovery. This recovery model is suitable for small databases where data loss is acceptable.
Example:
ALTER DATABASE [database_name]
SET RECOVERY SIMPLE
Full Recovery Model: In this recovery model, the transaction logs are not automatically truncated and the entire transaction history is retained until a log backup is taken. This recovery model supports point-in-time recovery and is suitable for large databases with a high level of data protection.
Example:
ALTER DATABASE [database_name]
SET RECOVERY FULL
Bulk-Logged Recovery Model: In this recovery model, some types of bulk operations (e.g. bulk import) are minimally logged and the transaction logs are not automatically truncated. This recovery model is a middle ground between simple and full recovery models and is suitable for large databases with a moderate level of data protection.
Example:
ALTER DATABASE [database_name]
SET RECOVERY BULK_LOGGED
Note - It's important to choose the appropriate recovery model for a database based on the data protection and performance requirements.
Comments
Post a Comment