View or change the recovery model of a database (SQL Server)
Applies to: SQL Server
This article describes how to view or change the database recovery model by using SQL Server Management Studio or Transact-SQL.
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. The model
database sets the default recovery model of new databases.
For an in-depth explanation, see recovery models.
Before you begin
Back up the transaction log before switching from the full recovery or bulk-logged recovery model.
Point-in-time recovery isn't possible with bulk-logged model. Running transactions under the bulk-logged recovery model that require a transaction log restore, can expose them to data loss. To maximize data recoverability in a disaster-recovery scenario, switch to the bulk-logged recovery model only under the following conditions:
Users are currently not allowed in the database.
All modifications made during bulk processing are recoverable without depending on taking a log backup; for example, by rerunning the bulk processes.
If you satisfy these two conditions, you aren't exposed to any data loss while restoring a transaction log that was backed up under the bulk-logged recovery model.
If you switch to the full recovery model during a bulk operation, bulk operations logging changes from minimal logging to full logging, and vice versa.
Permissions
Requires ALTER permission on the database.
Use SQL Server Management Studio
After connecting to the appropriate instance of the SQL Server Database Engine, in Object Explorer, select the server name to expand the server tree.
Expand Databases, and, depending on the database, either select a user database or expand System Databases and select a system database.
Right-click the database, and then select Properties, which opens the Database Properties dialog box.
In the Select a page pane, select Options.
The current recovery model is displayed in the Recovery model list box.
Optionally, to change the recovery model select a different model list. The choices are Full, Bulk-logged, or Simple.
Select OK.
Note
Plan cache entries for the database will be flushed or cleared.
Use Transact-SQL
View the recovery model
Connect to the Database Engine.
From the Standard bar, select New Query.
Copy and paste the following example into the query window and select Execute. This example shows how to query the sys.databases catalog view to learn the recovery model of the
model
database.
SELECT name, recovery_model_desc
FROM sys.databases
WHERE name = 'model';
GO
Change the recovery model
Connect to the Database Engine.
From the Standard bar, select New Query.
Copy and paste the following example into the query window and select Execute. This example shows how to change the recovery model in the
model
database toFULL
by using theSET RECOVERY
option of the ALTER DATABASE statement.
USE [master];
GO
ALTER DATABASE [model]
SET RECOVERY FULL;
GO
Note
Plan cache entries for the database will be flushed or cleared.
Recommendations: After you change the recovery model
After switching between the full and bulk-logged recovery models
After completing the bulk operations, immediately switch back to the full recovery model.
After switching from the bulk-logged recovery model back to the full recovery model, back up the log.
Your backup strategy remains the same: continue performing periodic database, log, and differential backups.
After switching from the simple recovery model
Immediately after switching to the full recovery model or bulk-logged recovery model, take a full or differential database backup to start the log chain.
The switch to the full or bulk-logged recovery model takes effect only after the first data backup.
Schedule regular log backups, and update your restore plan accordingly.
Important
Back up your logs. If you do not back up the log frequently enough, the transaction log can expand until it runs out of disk space.
After switching to the simple recovery model
Discontinue any scheduled jobs for backing up the transaction log.
Ensure periodic database backups are scheduled. Backing up your database is essential both to protect your data and to truncate the inactive portion of the transaction log.